Class: OctocatHerder::Base
- Inherits:
-
Object
- Object
- OctocatHerder::Base
- Defined in:
- lib/octocat_herder/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #available_attributes ⇒ Object
-
#initialize(raw_hash, conn = OctocatHerder::Connection.new) ⇒ Base
constructor
A new instance of Base.
- #method_missing(id, *args) ⇒ Object
Constructor Details
#initialize(raw_hash, conn = OctocatHerder::Connection.new) ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/octocat_herder/base.rb', line 12 def initialize(raw_hash, conn = OctocatHerder::Connection.new) @connection = conn @raw = raw_hash end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/octocat_herder/base.rb', line 17 def method_missing(id, *args) unless @raw and @raw.keys.include?(id.id2name) raise NoMethodError.new("undefined method #{id.id2name} for #{self}:#{self.class}") end @raw[id.id2name] end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/octocat_herder/base.rb', line 10 def connection @connection end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
10 11 12 |
# File 'lib/octocat_herder/base.rb', line 10 def raw @raw end |
Instance Method Details
#available_attributes ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/octocat_herder/base.rb', line 25 def available_attributes attrs = [] attrs += @raw.keys.reject do |k| [ 'id', 'type', ].include? k end if @raw (attrs + additional_attributes).uniq end |