Class: Flatpack::Core::Packer
- Inherits:
-
Object
- Object
- Flatpack::Core::Packer
- Includes:
- MapInitialize
- Defined in:
- lib/flatpack/core/packer.rb
Instance Attribute Summary collapse
-
#pretty ⇒ Object
Returns the value of attribute pretty.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#pack(entity) ⇒ Object
Generate a FlatPack JSON string from the given entity.
Methods included from MapInitialize
Instance Attribute Details
#pretty ⇒ Object
Returns the value of attribute pretty.
10 11 12 |
# File 'lib/flatpack/core/packer.rb', line 10 def pretty @pretty end |
#verbose ⇒ Object
Returns the value of attribute verbose.
10 11 12 |
# File 'lib/flatpack/core/packer.rb', line 10 def verbose @verbose end |
Instance Method Details
#pack(entity) ⇒ Object
Generate a FlatPack JSON string from the given entity
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/flatpack/core/packer.rb', line 13 def pack(entity) return {} unless entity @uuid_stack = [] @all_entities = {} @data = {} recursive_pack(entity) json = { :data => @data, :value => entity.uuid } json = @pretty ? JSON.pretty_generate(json) : json.to_json if(@verbose) puts "*** Serializing #{entity.entity_name} to FlatPack ***" puts json end json end |