Movatterモバイル変換


[0]ホーム

URL:


Libraries »piotrmurach/github(master) »Index (C) »Github »API »Config

Class: Github::API::Config

Inherits:
Object
  • Object
  • Github::API::Config
show all
Defined in:
lib/github_api/api/config.rb,
lib/github_api/api/config/property.rb,
lib/github_api/api/config/property_set.rb

Overview

A base class for constructing api configuration

Direct Known Subclasses

Configuration

Defined Under Namespace

Classes:Property,PropertySet

Class Attribute Summarycollapse

Class Method Summarycollapse

Instance Method Summarycollapse

Constructor Details

#initialize(&block) ⇒Config

Returns a new instance of Config.

646566
# File 'lib/github_api/api/config.rb', line 64definitialize(&block)super(&block)end

Class Attribute Details

.property_setObject(readonly)

Returns the value of attribute property_set.

525354
# File 'lib/github_api/api/config.rb', line 52defproperty_set@property_setend

Class Method Details

.inherited(descendant) ⇒Object

575859606162
# File 'lib/github_api/api/config.rb', line 57defself.inherited(descendant)super(@subclasses||=Set.new)<<descendantdescendant.instance_variable_set('@property_set',PropertySet.new(descendant,self.property_set.properties.dup))end

.property(name, options = {}) ⇒self

Defines a property on an object’s class or instance

Examples:

classConfiguration<Api::Configproperty:adapter,default::net_httpproperty:user,required:trueend

Parameters:

  • name(Symbol)

    the name of a property

  • options(#to_hash)(defaults to:{})

    the extra options

Returns:

  • (self)
2728293031
# File 'lib/github_api/api/config.rb', line 27defself.property(name,options={})self.property_set<<Property.new(name,options)update_subclasses(name,options)selfend

.property?(name) ⇒Boolean

Check if property is defined

Parameters:

  • name(Symbol)

    the name to check

Returns:

  • (Boolean)
474849
# File 'lib/github_api/api/config.rb', line 47defself.property?(name)property_set.include?(name)end

.property_namesObject

727374
# File 'lib/github_api/api/config.rb', line 72defself.property_namesproperty_set.properties.map(&:name)end

.update_subclasses(name, options) ⇒Object

3334353637
# File 'lib/github_api/api/config.rb', line 33defself.update_subclasses(name,options)ifdefined?(@subclasses)&&@subclasses@subclasses.each{|klass|klass.property(name,options)}endend

Instance Method Details

#call(&block) ⇒self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Provide access to properties

Examples:

config.calldo|config|config.adapter=:net_httpend

Returns:

  • (self)
99100101102
# File 'lib/github_api/api/config.rb', line 99defcall(&block)block.call(self)ifblock_given?selfend

#fetch(value = nil) ⇒Hash[Symbol]

Fetch all the properties and their values

Returns:

81828384858687
# File 'lib/github_api/api/config.rb', line 81deffetch(value=nil)ifvalueself.class.property_set[value]elseself.class.property_set.to_hashendend

#property_namesObject

686970
# File 'lib/github_api/api/config.rb', line 68defproperty_namesself.class.property_set.properties.map(&:name)end
Generated on Sun Nov 30 07:45:40 2025 byyard 0.9.37 (ruby-3.4.3).

[8]ページ先頭

©2009-2025 Movatter.jp