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 " def \#{name}\n data[:\#{name}]\n end\n RUBY\n end\nend\n", __FILE__, __LINE__ + 1 |
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 |
#type ⇒ Object
26 27 28 |
# File 'lib/cupid/response/object.rb', line 26 def type instance_of?(Object) ? self[:type] : self.class end |