Sha256: 1b8448c5fcd50fc2b58c1aece2f770ce997acd0cc57f1a979a1c26f92e50d005

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

module DataMapper
  class Property
    class String < Object
      load_as         ::String
      dump_as         ::String
      coercion_method :to_string

      accept_options :length

      DEFAULT_LENGTH = 50
      length(DEFAULT_LENGTH)

      # Returns maximum property length (if applicable).
      # This usually only makes sense when property is of
      # type Range or custom
      #
      # @return [Integer, nil]
      #   the maximum length of this property
      #
      # @api semipublic
      def length
        if @length.kind_of?(Range)
          @length.max
        else
          @length
        end
      end

    protected

      def initialize(model, name, options = {})
        super
        @length = @options.fetch(:length)
      end

    end # class String
  end # class Property
end # module DataMapper

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghost_dm-core-1.3.0.beta lib/dm-core/property/string.rb