Class: Jeweler::Service

Inherits:
Object show all
Defined in:
lib/jeweler/service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



7
8
9
# File 'lib/jeweler/service.rb', line 7

def errors
  @errors
end

#fatalsObject

Returns the value of attribute fatals.



7
8
9
# File 'lib/jeweler/service.rb', line 7

def fatals
  @fatals
end

#resultObject

Returns the value of attribute result.



7
8
9
# File 'lib/jeweler/service.rb', line 7

def result
  @result
end

#result_messageObject

Returns the value of attribute result_message.



7
8
9
# File 'lib/jeweler/service.rb', line 7

def result_message
  @result_message
end

Class Method Details

.call(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jeweler/service.rb', line 9

def self.call(*args)

  new(*args).tap do |service|
    service.instance_variable_set('@errors', Array.new)
    service.instance_variable_set('@fatals', Array.new)
    service.instance_variable_set('@result_message', '')

    service.instance_variable_set("@result", service.call)

    tapped_errors = service.instance_variable_get('@errors')
    tapped_fatals = service.instance_variable_get('@fatals')

    first_fatal = true
    tapped_fatals.each do |fatal|
      Rails.logger.error 'ServiceObject Fatal Error: ' + fatal
      if first_fatal
        tapped_errors << 'There was an error. Contact Support.'
        first_fatal = false
      end
    end

    service.instance_variable_set('@errors', tapped_errors)

  end
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/jeweler/service.rb', line 35

def call
  raise NotImplementedError
end