Sha256: 5678aab00f2346053e621a0ae39f2938f3f159ba78efc333e7e1a00721d2dd4b

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

class Transcriber::Resource
  class Property
    autoload :Parser,   'transcriber/resource/properties/parser'
    autoload :Resource, 'transcriber/resource/properties/resource'
    include   Parser
    include   Resource

    attr_accessor :name
    attr_accessor :field
    attr_accessor :serializer
    attr_accessor :values
    attr_accessor :options

    def initialize(name, options = {})
      @name  = name
      @field = prepare_field(options.delete(:field) || name)
      @serializer = (options.delete(:type)  || Serialization::String)
      @values     =  options.delete(:values)
      @options    =  options
    end

    def prepare_field(field)
      field.to_s.upcase # @TODO this logic shouldn't be here.
                        # it's a key conversion strategy
                        # convert(field).to_s, convert should be
                        # an identity function if a custom
                        # strategy was not set.
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transcriber-0.0.1 lib/transcriber/resource/properties/property.rb