Sha256: 1cb33e93ebbb48fafce03400683d9512411a353e1dda4a2526b0659ad62d354f

Contents?: true

Size: 699 Bytes

Versions: 3

Compression:

Stored size: 699 Bytes

Contents

module ActiveDynamic
  class AttributeDefinition

    attr_reader :display_name, :datatype, :value, :name, :required

    def initialize(display_name, params = {})
      options = params.dup
      @name = (options.delete(:system_name) || display_name).parameterize.underscore
      @display_name = display_name
      @datatype = options.delete(:datatype)
      @value = options.delete(:default_value)
      @required = options.delete(:required) || false

      # custom attributes from Provider
      options.each do |key, value|
        self.instance_variable_set("@#{key}", value)
        self.class.send(:attr_reader, key)
      end
    end

    def required?
      !!@required
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_dynamic-0.5.9 lib/active_dynamic/attribute_definition.rb
active_dynamic-0.5.8 lib/active_dynamic/attribute_definition.rb
active_dynamic-0.5.7 lib/active_dynamic/attribute_definition.rb