A class responsible for handling request arguments
'auto_pagination'.freeze
Validations::Token::TOKEN_REQUIRED,Validations::Token::TOKEN_REQUIRED_REGEXP
The request api.
Parameters passed to request.
The remaining unparsed arguments.
Hash like access to request arguments.
Check if required keys are present inside parameters hash.
Check if parameters match expected values.
Initialize an Arguments.
Specify optional attribute(s).
Parse arguments to allow for flexible api calls.
Remove unknown keys from parameters hash.
Specify required attribute(s).
Initialize an Arguments
Parameters:
Options Hash (options):
arguments that must be present before request is fired
the reference to the current api
38394041424344454647 | # File 'lib/github_api/api/arguments.rb', line 38definitialize(={},&block)normalize!@api=.fetch('api')@required=.fetch('required',[]).map(&:to_s)@optional=.fetch('optional',[]).map(&:to_s)@assigns={}yield_or_eval(&block)end |
This class handles dynamic methods through themethod_missing method
79808182838485 | # File 'lib/github_api/api/arguments.rb', line 79defmethod_missing(method_name,*args,&block)if@assigns.key?(method_name.to_s)self[method_name]elsesuperendend |
The request api
252627 | # File 'lib/github_api/api/arguments.rb', line 25defapi@apiend |
Parameters passed to request
192021 | # File 'lib/github_api/api/arguments.rb', line 19defparams@paramsend |
The remaining unparsed arguments
222324 | # File 'lib/github_api/api/arguments.rb', line 22defremaining@remainingend |
Hash like access to request arguments
Parameters:
the property name
717273 | # File 'lib/github_api/api/arguments.rb', line 71def[](property)@assigns[property.to_s]end |
757677 | # File 'lib/github_api/api/arguments.rb', line 75def[]=(property,value)@assigns[property.to_s]=valueend |
Check if required keys are present inside parameters hash.
126127128129 | # File 'lib/github_api/api/arguments.rb', line 126defassert_required(*required)assert_required_keys(required,params)selfend |
Check if parameters match expected values.
134135136137 | # File 'lib/github_api/api/arguments.rb', line 134defassert_values(values,key=nil)assert_valid_valuesvalues,(key.nil??params:params[key])selfend |
Specify optional attribute(s)
6263 | # File 'lib/github_api/api/arguments.rb', line 62defoptional(*attrs,&block)end |
Parse arguments to allow for flexible api calls
Arguments can be part of parameters hash or be simple string arguments.
96979899100101102103104105106107108109110111 | # File 'lib/github_api/api/arguments.rb', line 96defparse(*args,&block)=ParamsHash.new(args.)normalize!ifargs.size.zero?# Arguments are inside the parameters hashparse_hash()elseparse_array(*args)end@params=@remaining=args[@required.size..-1]extract_pagination()yield_or_eval(&block)selfend |
Remove unknown keys from parameters hash.
:recursive - boolean that toggles whether nested filtering should be applied118119120121 | # File 'lib/github_api/api/arguments.rb', line 118defpermit(keys,key=nil,={})filter!keys,(key.nil??params:params[key]),ifkeys.any?selfend |
Specify required attribute(s)
5253545556 | # File 'lib/github_api/api/arguments.rb', line 52defrequire(*attrs,&block)attrs_clone=attrs.clone@required=Array(attrs_clone)selfend |
Returns:
878889 | # File 'lib/github_api/api/arguments.rb', line 87defrespond_to_missing?(method_name,include_private=false)@assigns.key?(method_name)||superend |