Sha256: ba374ce2fa36223eecd38346ee1af4f423ce15eae976e9455e7b0e2a8208ef86

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 Bytes

Contents

module Transcriber
  class Resource
    class Property < Key
      include Parser::Property
      include Response::Property

      attr_accessor :serializer
      attr_accessor :translations

      def initialize(name, options = {})
        super
        @serializer   = options.fetch(:type, Serialization::String)
        @translations = options[:values]        if options[:values].kind_of?(Proc)
        @translations = options[:values].invert if options[:values].kind_of?(Hash)
      end

      def from_hash(value)
        value
      end

      def to_input(value, options = {})
        value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transcriber-0.0.15 lib/transcriber/resource/key/property.rb
transcriber-0.0.14 lib/transcriber/resource/key/property.rb