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
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.
12 13 14 |
# File 'lib/nform/service.rb', line 12 def initialize(input) @form = get_form(input) end |
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
11 12 13 |
# File 'lib/nform/service.rb', line 11 def form @form end |
Class Method Details
.call(*args) ⇒ Object
20 21 22 |
# File 'lib/nform/service.rb', line 20 def self.call(*args) new(*args).call end |
.form_class(klass = nil) ⇒ Object
24 25 26 |
# File 'lib/nform/service.rb', line 24 def self.form_class(klass=nil) @@form_class = klass || const_get(:Form) end |
Instance Method Details
#call ⇒ Object
16 17 18 |
# File 'lib/nform/service.rb', line 16 def call raise "Must be defined in subclass" end |