Class: Woodhouse::LayoutSerializer
- Inherits:
-
Object
- Object
- Woodhouse::LayoutSerializer
- Defined in:
- lib/woodhouse/layout_serializer.rb
Defined Under Namespace
Classes: LayoutLoader
Class Method Summary collapse
Instance Method Summary collapse
- #as_hash ⇒ Object
-
#initialize(layout) ⇒ LayoutSerializer
constructor
A new instance of LayoutSerializer.
- #to_json ⇒ Object
Constructor Details
#initialize(layout) ⇒ LayoutSerializer
Returns a new instance of LayoutSerializer.
5 6 7 |
# File 'lib/woodhouse/layout_serializer.rb', line 5 def initialize(layout) @layout = layout end |
Class Method Details
.dump(layout) ⇒ Object
19 20 21 |
# File 'lib/woodhouse/layout_serializer.rb', line 19 def self.dump(layout) new(layout).to_json end |
.load(json) ⇒ Object
23 24 25 |
# File 'lib/woodhouse/layout_serializer.rb', line 23 def self.load(json) LayoutLoader.new(json).layout end |
Instance Method Details
#as_hash ⇒ Object
9 10 11 12 13 |
# File 'lib/woodhouse/layout_serializer.rb', line 9 def as_hash { :nodes => node_list(layout.nodes) } end |
#to_json ⇒ Object
15 16 17 |
# File 'lib/woodhouse/layout_serializer.rb', line 15 def to_json as_hash.to_json end |