Sha256: 3884cee155f903280d01b700508ce5d6ed51b6d96e0ff924e15a4f877694817a

Contents?: true

Size: 438 Bytes

Versions: 14

Compression:

Stored size: 438 Bytes

Contents

class Serializers
  class Base
    @@structures = {}

    def self.structure(type, &blk)
      @@structures["#{self.name}::#{type}"] = blk
    end

    def initialize(type)
      @type = type
    end

    def serialize(object)
      object.respond_to?(:map) ? object.map{|item| serializer.call(item)} : serializer.call(object)
    end

    private

    def serializer
      @@structures["#{self.class.name}::#{@type}"]
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pliny-0.8.2 lib/template/lib/serializers/base.rb
pliny-0.8.1 lib/template/lib/serializers/base.rb
pliny-0.8.0 lib/template/lib/serializers/base.rb
pliny-0.7.3 lib/template/lib/serializers/base.rb
pliny-0.7.2 lib/template/lib/serializers/base.rb
pliny-0.7.1 lib/template/lib/serializers/base.rb
pliny-0.7.0 lib/template/lib/serializers/base.rb
pliny-0.6.3 lib/template/lib/serializers/base.rb
pliny-0.6.2 lib/template/lib/serializers/base.rb
pliny-0.6.1 lib/template/lib/serializers/base.rb
pliny-0.6.0 lib/template/lib/serializers/base.rb
pliny-0.5.0 template/lib/serializers/base.rb
pliny-0.4.0 template/lib/serializers/base.rb
pliny-0.3.0 template/lib/serializers/base.rb