Class: NForm::Service

Inherits:
Object
  • Object
show all
Includes:
Hashable
Defined in:
lib/nform/service.rb

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hashable

#hash_of

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

#formObject (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

#callObject



16
17
18
# File 'lib/nform/service.rb', line 16

def call
  raise "Must be defined in subclass"
end