Class responsible for storing configuration properties
Instance Attribute Summary collapseReturns the value of attribute parent.
Returns the value of attribute properties.
Adds property to the set.
Access property by name.
Set property value by name.
Iterate over properties.
Check if properties exist.
Initialize an PropertySet.
Convert properties to a hash of property names and corresponding values.
Update map with index.
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.
Initialize an PropertySet
24 25 26 27 28
# File 'lib/github_api/api/config/property_set.rb', line 24 def initialize(parent = nil, properties = Set.new) @parent = parent @properties = properties @map = {} endInstance Attribute Details #parent ⇒ Object
Returns the value of attribute parent.
12 13 14
# File 'lib/github_api/api/config/property_set.rb', line 12 def parent @parent end#properties ⇒ Object
Returns the value of attribute properties.
14 15 16
# File 'lib/github_api/api/config/property_set.rb', line 14 def properties @properties endInstance Method Details #<<(property) ⇒ self
55 56 57 58 59 60
# File 'lib/github_api/api/config/property_set.rb', line 55 def <<(property) properties << property update_map(property.name, property.default) property.define_accessor_methods(self) self end#[](name) ⇒ Object Also known as: fetch
65 66 67
# File 'lib/github_api/api/config/property_set.rb', line 65 def [](name) @map[name] end#[]=(name, property) ⇒ Object
Set property value by name
73 74 75
# File 'lib/github_api/api/config/property_set.rb', line 73 def []=(name, property) update_map(name, property) end#define_reader_method(property, method_name, visibility) ⇒ Object
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.
103 104 105 106 107
# File 'lib/github_api/api/config/property_set.rb', line 103 def define_reader_method(property, method_name, visibility) property_set = self parent.send(:define_method, method_name) { property_set[property.name] } parent.send(visibility, method_name) end#define_writer_method(property, method_name, visibility) ⇒ Object
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.
110 111 112 113 114 115 116
# File 'lib/github_api/api/config/property_set.rb', line 110 def define_writer_method(property, method_name, visibility) property_set = self parent.send(:define_method, method_name) do |value| property_set[property.name]= value end parent.send(visibility, method_name) end#each {|property| ... } ⇒ self
39 40 41 42 43
# File 'lib/github_api/api/config/property_set.rb', line 39 def each return to_enum unless block_given? @map.each { |name, property| yield property if name.is_a?(Symbol) } self end#empty? ⇒ Boolean
Check if properties exist
98 99 100
# File 'lib/github_api/api/config/property_set.rb', line 98 def empty? @map.empty? end#to_hash ⇒ Object
Convert properties to a hash of property names and corresponding values
88 89 90 91 92 93
# File 'lib/github_api/api/config/property_set.rb', line 88 def to_hash properties.each_with_object({}) do |property, props| name = property.name props[name] = self[name] end end#update_map(name, property) ⇒ Object
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.
Update map with index
80 81 82
# File 'lib/github_api/api/config/property_set.rb', line 80 def update_map(name, property) @map[name.to_sym] = @map[name.to_s.freeze] = property 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