Movatterモバイル変換


[0]ホーム

URL:


Libraries »piotrmurach/github(master) »Index (A) »Github »API »Arguments

Class: Github::API::Arguments

Inherits:
Object
  • Object
  • Github::API::Arguments
show all
Includes:
Normalizer,ParameterFilter,Validations
Defined in:
lib/github_api/api/arguments.rb

Overview

A class responsible for handling request arguments

Constant Summarycollapse

AUTO_PAGINATION =
'auto_pagination'.freeze

Constants included fromValidations

Validations::VALID_API_KEYS

Constants included fromValidations::Token

Validations::Token::TOKEN_REQUIRED,Validations::Token::TOKEN_REQUIRED_REGEXP

Instance Attribute Summarycollapse

Instance Method Summarycollapse

Methods included fromValidations::Required

#assert_required_keys

Methods included fromValidations::Token

#validates_token_for

Methods included fromValidations::Format

#assert_valid_values

Methods included fromValidations::Presence

#assert_presence_of

Methods included fromParameterFilter

#filter!

Methods included fromNormalizer

#normalize!

Constructor Details

#initialize(options = {}, &block) ⇒Arguments

Initialize an Arguments

Parameters:

  • options(Hash)(defaults to:{})

Options Hash (options):

  • :required(Array[String])

    arguments that must be present before request is fired

  • :api(Github::API)

    the reference to the current api

38394041424344454647
# File 'lib/github_api/api/arguments.rb', line 38definitialize(options={},&block)normalize!options@api=options.fetch('api')@required=options.fetch('required',[]).map(&:to_s)@optional=options.fetch('optional',[]).map(&:to_s)@assigns={}yield_or_eval(&block)end

Dynamic Method Handling

This class handles dynamic methods through themethod_missing method

#method_missing(method_name, *args, &block) ⇒Object

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

Instance Attribute Details

#apiObject(readonly)

The request api

252627
# File 'lib/github_api/api/arguments.rb', line 25defapi@apiend

#paramsObject(readonly)

Parameters passed to request

192021
# File 'lib/github_api/api/arguments.rb', line 19defparams@paramsend

#remainingObject(readonly)

The remaining unparsed arguments

222324
# File 'lib/github_api/api/arguments.rb', line 22defremaining@remainingend

Instance Method Details

#[](property) ⇒Object

Hash like access to request arguments

Parameters:

  • property(String,Symbol)

    the property name

717273
# File 'lib/github_api/api/arguments.rb', line 71def[](property)@assigns[property.to_s]end

#[]=(property, value) ⇒Object

757677
# File 'lib/github_api/api/arguments.rb', line 75def[]=(property,value)@assigns[property.to_s]=valueend

#assert_required(*required) ⇒Object

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

#assert_values(values, key = nil) ⇒Object

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

#optional(*attrs, &block) ⇒Object

Specify optional attribute(s)

6263
# File 'lib/github_api/api/arguments.rb', line 62defoptional(*attrs,&block)end

#parse(*args, &block) ⇒Object

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)options=ParamsHash.new(args.extract_options!)normalize!optionsifargs.size.zero?# Arguments are inside the parameters hashparse_hash(options)elseparse_array(*args)end@params=options@remaining=args[@required.size..-1]extract_pagination(options)yield_or_eval(&block)selfend

#permit(keys, key = nil, options = {}) ⇒Object

Remove unknown keys from parameters hash.

Parameters

:recursive - boolean that toggles whether nested filtering should be applied
118119120121
# File 'lib/github_api/api/arguments.rb', line 118defpermit(keys,key=nil,options={})filter!keys,(key.nil??params:params[key]),optionsifkeys.any?selfend

#require(*attrs, &block) ⇒ObjectAlso known as:required

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

#respond_to_missing?(method_name, include_private = false) ⇒Boolean

Returns:

  • (Boolean)
878889
# File 'lib/github_api/api/arguments.rb', line 87defrespond_to_missing?(method_name,include_private=false)@assigns.key?(method_name)||superend
Generated on Sat Nov 22 21:04:24 2025 byyard 0.9.37 (ruby-3.4.3).

[8]ページ先頭

©2009-2025 Movatter.jp