Class: Moo::Model::BoxData
Instance Attribute Summary collapse
-
#colour ⇒ Object
Returns the value of attribute colour.
Attributes inherited from Data
Instance Method Summary collapse
- #from_json(json) ⇒ Object
-
#initialize {|_self| ... } ⇒ BoxData
constructor
A new instance of BoxData.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from Data
Constructor Details
#initialize {|_self| ... } ⇒ BoxData
Returns a new instance of BoxData.
7 8 9 |
# File 'lib/moo/model/box_data.rb', line 7 def initialize yield self if block_given? end |
Instance Attribute Details
#colour ⇒ Object
Returns the value of attribute colour.
5 6 7 |
# File 'lib/moo/model/box_data.rb', line 5 def colour @colour end |
Instance Method Details
#from_json(json) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/moo/model/box_data.rb', line 30 def from_json json hash = JSON.parse json, :symbolize_names => true @link_id = hash[:linkId] @colour = Colour.new @colour.from_json(hash[:colour].to_json) end |
#to_hash ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/moo/model/box_data.rb', line 22 def to_hash { :linkId => link_id, :type => 'boxData', :colour => colour.to_hash } end |
#to_json ⇒ Object
18 19 20 |
# File 'lib/moo/model/box_data.rb', line 18 def to_json to_hash.to_json end |