Class: Lecter::FormatterPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/lecter/formatter_payload.rb

Constant Summary collapse

WRONG_PARAMETERS_MSG =
'Wrong parameters'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ FormatterPayload

Returns a new instance of FormatterPayload.



10
11
12
# File 'lib/lecter/formatter_payload.rb', line 10

def initialize(payload)
  @dirty_payload = payload
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the value of attribute error_message.



8
9
10
# File 'lib/lecter/formatter_payload.rb', line 8

def error_message
  @error_message
end

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/lecter/formatter_payload.rb', line 8

def result
  @result
end

Instance Method Details

#callObject



14
15
16
17
18
19
# File 'lib/lecter/formatter_payload.rb', line 14

def call
  @result = json_parse(dirty_payload).merge(lecter_enabled_parameter)
rescue JSON::ParserError
  @error_message = WRONG_PARAMETERS_MSG
  false
end