Class: Cupid::Response::Object
- Inherits:
-
Object
- Object
- Cupid::Response::Object
- Defined in:
- lib/cupid/response/object.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #==(object) ⇒ Object
- #[](field) ⇒ Object
-
#call ⇒ Object
Hook into gyoku.
-
#initialize(data) ⇒ Object
constructor
A new instance of Object.
- #type ⇒ Object
Constructor Details
#initialize(data) ⇒ Object
Returns a new instance of Object.
17 18 19 |
# File 'lib/cupid/response/object.rb', line 17 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/cupid/response/object.rb', line 14 def data @data end |
Class Method Details
.fields(*names) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/cupid/response/object.rb', line 4 def self.fields(*names) names.each do |name| class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} data[:#{name}] end RUBY end end |
Instance Method Details
#==(object) ⇒ Object
30 31 32 33 |
# File 'lib/cupid/response/object.rb', line 30 def ==(object) return false unless object.is_a? Cupid::Response::Object id and [id, type] == [object.id, object.type] end |
#[](field) ⇒ Object
35 36 37 |
# File 'lib/cupid/response/object.rb', line 35 def [](field) data[field] end |
#call ⇒ Object
Hook into gyoku
22 23 24 |
# File 'lib/cupid/response/object.rb', line 22 def call id end |