Class: Moo::Model::BoxData

Inherits:
Data show all
Defined in:
lib/moo/model/box_data.rb

Instance Attribute Summary collapse

Attributes inherited from Data

#link_id

Instance Method Summary collapse

Methods inherited from Data

#type

Constructor Details

#initialize {|_self| ... } ⇒ BoxData

Returns a new instance of BoxData.

Yields:

  • (_self)

Yield Parameters:



7
8
9
# File 'lib/moo/model/box_data.rb', line 7

def initialize
  yield self if block_given?
end

Instance Attribute Details

#colourObject

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_hashObject



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_jsonObject



18
19
20
# File 'lib/moo/model/box_data.rb', line 18

def to_json
  to_hash.to_json
end