Class: Serializers::Base
- Inherits:
-
Object
- Object
- Serializers::Base
- Extended by:
- Pliny::Helpers::ZuluTime
- Defined in:
- lib/template/lib/serializers/base.rb
Constant Summary collapse
- @@structures =
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type) ⇒ Base
constructor
A new instance of Base.
- #serialize(object) ⇒ Object
Methods included from Pliny::Helpers::ZuluTime
Constructor Details
#initialize(type) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/template/lib/serializers/base.rb', line 11 def initialize(type) @type = type end |
Class Method Details
.structure(type, &blk) ⇒ Object
7 8 9 |
# File 'lib/template/lib/serializers/base.rb', line 7 def self.structure(type, &blk) @@structures["#{name}::#{type}"] = blk end |
Instance Method Details
#serialize(object) ⇒ Object
15 16 17 |
# File 'lib/template/lib/serializers/base.rb', line 15 def serialize(object) object.respond_to?(:map) ? object.map { |item| serializer.call(item) } : serializer.call(object) end |