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.



13
14
15
# File 'lib/nform/service.rb', line 13

def initialize(input)
  @form = get_form(input)
end

Instance Attribute Details

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

#callObject



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

def call
  raise "Must be defined in subclass"
end