Sha256: 68b0347d4d5ef8307d66251fc1b6348d7237f82f9703e79c3a1af475aab03efc

Contents?: true

Size: 679 Bytes

Versions: 2

Compression:

Stored size: 679 Bytes

Contents

module ActiveDynamic
  class AttributeDefinition

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

    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)

      # 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

2 entries across 2 versions & 1 rubygems

Version Path
active_dynamic-0.5.6 lib/active_dynamic/attribute_definition.rb
active_dynamic-0.5.5 lib/active_dynamic/attribute_definition.rb