Object
A base class for constructing api configuration
# File lib/github_api/api/config.rb, line 58 def self.inherited(descendant) super (@subclasses ||= Set.new) << descendant descendant.instance_variable_set('@property_set', PropertySet.new(descendant, self.property_set.properties.dup)) end
# File lib/github_api/api/config.rb, line 65 def initialize(&block) super(&block) end
Defines a property on an object’s class or instance
@example
class Configuration < Api::Config property :adapter, default: :net_http property :user, required: true end
@param [Symbol] name
the name of a property
@param [to_hash] options
the extra options
@return [self]
@api public
# File lib/github_api/api/config.rb, line 28 def self.property(name, options = {}) self.property_set << Property.new(name, options) update_subclasses(name, options) self end
Check if property is defined
@param [Symbol] name
the name to check
@return [Boolean]
@api public
# File lib/github_api/api/config.rb, line 48 def self.property?(name) property_set.include?(name) end
Provide access to properties
@example
config.call do |config| config.adapter = :net_http end
@return [self]
@api private
# File lib/github_api/api/config.rb, line 100 def call(&block) block.call(self) if block_given? self end
Fetach all the properties and their values
@return [Hash]
@api public
# File lib/github_api/api/config.rb, line 82 def fetch(value = nil) if value self.class.property_set[value] else self.class.property_set.to_hash end end
Generated with the Darkfish Rdoc Generator 2.