Sha256: 5a31067092feaca5374dadd308095f0e93c7adaaf5d5551a2b7c2cf413e0a35a

Contents?: true

Size: 852 Bytes

Versions: 15

Compression:

Stored size: 852 Bytes

Contents

require 'ardm/property/object'

module Ardm
  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 Ardm

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ardm-0.4.0.ar427 lib/ardm/property/string.rb
ardm-0.4.0 lib/ardm/property/string.rb
ardm-0.3.2 lib/ardm/property/string.rb
ardm-0.3.1 lib/ardm/property/string.rb
ardm-0.3.0 lib/ardm/property/string.rb
ardm-0.2.7 lib/ardm/property/string.rb
ardm-0.2.6 lib/ardm/property/string.rb
ardm-0.2.5 lib/ardm/property/string.rb
ardm-0.2.4 lib/ardm/property/string.rb
ardm-0.2.3 lib/ardm/property/string.rb
ardm-0.2.2 lib/ardm/property/string.rb
ardm-0.2.1 lib/ardm/property/string.rb
ardm-0.2.0 lib/ardm/property/string.rb
ardm-0.1.0 lib/ardm/property/string.rb
ardm-0.0.1 lib/ardm/property/string.rb