Module: SlimFormObject::ClassMethods
- Defined in:
- lib/slim_form_object/processing.rb
Instance Method Summary collapse
Instance Method Details
#add_attributes(models) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/slim_form_object/processing.rb', line 19 def add_attributes(models) #attr_accessor for models and env params attr_accessor :params models.each{ |model| attr_accessor snake(model.to_s).to_sym } #delegate attributes of models models.each do |model| model.column_names.each do |attr| delegate attr.to_sym, "#{attr}=".to_sym, to: snake(model.to_s).to_sym, prefix: snake(model.to_s).to_sym end end end |
#init_models(*args) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/slim_form_object/processing.rb', line 12 def init_models(*args) self.instance_eval do define_method(:array_of_models) { args } end add_attributes(args) end |
#set_model_name(name) ⇒ Object
34 35 36 |
# File 'lib/slim_form_object/processing.rb', line 34 def set_model_name(name) define_method(:model_name) { ActiveModel::Name.new(self, nil, name) } end |