Module: NuecaRailsInterfaces::V2::FormInterface
- Defined in:
- lib/nueca_rails_interfaces/v2/form_interface.rb
Overview
V2 Form Interface is the same as V1 Form Interface, except forces an exception on the attributes method when intializing a form.
Class Method Summary collapse
-
.included(base) ⇒ Object
Allows the form mixin to include ActiveModel::Model powers.
Instance Method Summary collapse
-
#attributes ⇒ Object
Final attributes to be returned by the form after validation.
-
#initialize(options = {}) ⇒ Object
Initializes the form with the options passed in.
Class Method Details
.included(base) ⇒ Object
Allows the form mixin to include ActiveModel::Model powers.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nueca_rails_interfaces/v2/form_interface.rb', line 10 def included(base) base.include(ActiveModel::Model) # Initializes the form in a class context with the options passed in. base.define_singleton_method(:check) do |*arguments| instance = NuecaRailsInterfaces::Util.process_class_arguments(self, *arguments) instance.valid? instance end end |
Instance Method Details
#attributes ⇒ Object
Final attributes to be returned by the form after validation. This is the data that is expected of the form to produce for processing.
32 33 34 |
# File 'lib/nueca_rails_interfaces/v2/form_interface.rb', line 32 def attributes raise NotImplementedError, 'Requires implementation of attributes.' end |
#initialize(options = {}) ⇒ Object
Initializes the form with the options passed in. It also calls the attributes method to ensure it is implemented.
24 25 26 27 |
# File 'lib/nueca_rails_interfaces/v2/form_interface.rb', line 24 def initialize( = {}) super(**) attributes end |