Sha256: 22eb0bb78044e251afed01b81af2cba9ba67358c6b89b79b09de142e895626d9

Contents?: true

Size: 397 Bytes

Versions: 13

Compression:

Stored size: 397 Bytes

Contents

module Superstore
  module AttributeMethods
    class Definition
      attr_reader :name, :type
      def initialize(model, name, type_class, options)
        @name = name.to_s
        @type = type_class.new(model, options)
      end

      def instantiate(value)
        return if value.nil?

        value.kind_of?(String) ? type.decode(value) : type.typecast(value)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
superstore-2.4.4 lib/superstore/attribute_methods/definition.rb
superstore-2.4.3 lib/superstore/attribute_methods/definition.rb
superstore-2.4.2 lib/superstore/attribute_methods/definition.rb
superstore-2.4.1 lib/superstore/attribute_methods/definition.rb
superstore-2.4.0 lib/superstore/attribute_methods/definition.rb
superstore-2.3.0 lib/superstore/attribute_methods/definition.rb
superstore-2.2.0 lib/superstore/attribute_methods/definition.rb
superstore-2.1.3 lib/superstore/attribute_methods/definition.rb
superstore-2.1.2 lib/superstore/attribute_methods/definition.rb
superstore-2.1.1 lib/superstore/attribute_methods/definition.rb
superstore-2.1.0 lib/superstore/attribute_methods/definition.rb
superstore-2.0.1 lib/superstore/attribute_methods/definition.rb
superstore-2.0.0 lib/superstore/attribute_methods/definition.rb