Class: Trailblazer::Rails::Form

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/trailblazer/rails/form.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delegated, model_class) ⇒ Form

Returns a new instance of Form.



3
4
5
6
# File 'lib/trailblazer/rails/form.rb', line 3

def initialize(delegated, model_class)
  super(delegated)
  @model_class = model_class
end

Class Method Details

.nameObject



8
9
10
11
# File 'lib/trailblazer/rails/form.rb', line 8

def self.name
  # for whatever reason, validations climb up the inheritance tree and require _every_ class to have a name (4.1).
  "Reform::Form"
end

Instance Method Details

#model_nameObject



13
14
15
# File 'lib/trailblazer/rails/form.rb', line 13

def model_name
  ::ActiveModel::Name.new(self, nil, @model_class.to_s.camelize)
end

#to_modelObject



17
18
19
# File 'lib/trailblazer/rails/form.rb', line 17

def to_model
  self
end