A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://rubydoc.info/github/piotrmurach/github/master/Github/API/Config below:

Config – Documentation for piotrmurach/github (master) – RubyDoc.info

Class: Github::API::Config
Inherits:
Object 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

Defined Under Namespace

Classes: Property, PropertySet

Class Attribute Summary collapse Class Method Summary collapse Instance Method Summary collapse Constructor Details #initialize(&block) ⇒ Config

Returns a new instance of Config.

64
65
66
# File 'lib/github_api/api/config.rb', line 64

def initialize(&block)
  super(&block)
end
Class Attribute Details .property_set ⇒ Object

Returns the value of attribute property_set.

52
53
54
# File 'lib/github_api/api/config.rb', line 52

def property_set
  @property_set
end
Class Method Details .inherited(descendant) ⇒ Object
57
58
59
60
61
62
# File 'lib/github_api/api/config.rb', line 57

def self.inherited(descendant)
  super
  (@subclasses ||= Set.new) << descendant
  descendant.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

27
28
29
30
31
# File 'lib/github_api/api/config.rb', line 27

def self.property(name, options = {})
  self.property_set << Property.new(name, options)
  update_subclasses(name, options)
  self
end
.property?(name) ⇒ Boolean

Check if property is defined

47
48
49
# File 'lib/github_api/api/config.rb', line 47

def self.property?(name)
  property_set.include?(name)
end
.property_names ⇒ Object
72
73
74
# File 'lib/github_api/api/config.rb', line 72

def self.property_names
  property_set.properties.map(&:name)
end
.update_subclasses(name, options) ⇒ Object
33
34
35
36
37
# File 'lib/github_api/api/config.rb', line 33

def self.update_subclasses(name, options)
  if defined?(@subclasses) && @subclasses
    @subclasses.each { |klass| klass.property(name, options) }
  end
end
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

99
100
101
102
# File 'lib/github_api/api/config.rb', line 99

def call(&block)
  block.call(self) if block_given?
  self
end
#fetch(value = nil) ⇒ Hash[Symbol]

Fetch all the properties and their values

81
82
83
84
85
86
87
# File 'lib/github_api/api/config.rb', line 81

def fetch(value = nil)
  if value
    self.class.property_set[value]
  else
    self.class.property_set.to_hash
  end
end
#property_names ⇒ Object
68
69
70
# File 'lib/github_api/api/config.rb', line 68

def property_names
  self.class.property_set.properties.map(&:name)
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4