Class: FormObj::Form::Attribute

Inherits:
Struct::Attribute show all
Defined in:
lib/form_obj/form/attribute.rb

Direct Known Subclasses

ModelMapper::Attribute

Instance Attribute Summary

Attributes inherited from Struct::Attribute

#name

Instance Method Summary collapse

Methods inherited from Struct::Attribute

#default_value, #subform?, #validate_value!

Constructor Details

#initialize(name, array: false, class: nil, default: nil, parent:, primary_key: nil, &block) ⇒ Attribute

Returns a new instance of Attribute.



4
5
6
7
8
# File 'lib/form_obj/form/attribute.rb', line 4

def initialize(name, array: false, class: nil, default: nil, parent:, primary_key: nil, &block)
  super(name, array: array, class: binding.local_variable_get(:class), default: default, parent: parent, primary_key: primary_key, &block)

  @nested_class.instance_variable_set(:@model_name, ActiveModel::Name.new(@nested_class, nil, name.to_s)) if !@nested_class && block_given?
end