Class: NForm::Service
Overview
Services expect valid input A service performs a single action A service should not accept unfiltered user input, but accept a form object when user input is required
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Class Method Summary collapse
- .call(*args) ⇒ Object
-
.form_class(klass = nil) ⇒ Object
Setter Macro.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(input) ⇒ Service
constructor
A new instance of Service.
Methods included from Hashable
Constructor Details
#initialize(input) ⇒ Service
Returns a new instance of Service.
13 14 15 |
# File 'lib/nform/service.rb', line 13 def initialize(input) @form = get_form(input) end |
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
12 13 14 |
# File 'lib/nform/service.rb', line 12 def form @form end |
Class Method Details
.call(*args) ⇒ Object
21 22 23 |
# File 'lib/nform/service.rb', line 21 def self.call(*args) new(*args).call end |
.form_class(klass = nil) ⇒ Object
Setter Macro
26 27 28 29 30 |
# File 'lib/nform/service.rb', line 26 def self.form_class(klass=nil) @form_class ||= begin klass || const_get(:Form) end end |
Instance Method Details
#call ⇒ Object
17 18 19 |
# File 'lib/nform/service.rb', line 17 def call raise "Must be defined in subclass" end |