Class: Itsf::Services::V2::Response::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Defined in:
lib/itsf/services/v2/response/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



12
13
14
15
# File 'lib/itsf/services/v2/response/base.rb', line 12

def initialize
  @messages = []
  @errors = ActiveModel::Errors.new(self)
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



8
9
10
# File 'lib/itsf/services/v2/response/base.rb', line 8

def errors
  @errors
end

#messagesObject

Returns the value of attribute messages.



9
10
11
# File 'lib/itsf/services/v2/response/base.rb', line 9

def messages
  @messages
end

#success=(value) ⇒ Object (writeonly)

Sets the attribute success

Parameters:

  • value

    the value to set the attribute success to.



10
11
12
# File 'lib/itsf/services/v2/response/base.rb', line 10

def success=(value)
  @success = value
end

Class Method Details

.human_attribute_name(attr, _options = {}) ⇒ Object



29
30
31
# File 'lib/itsf/services/v2/response/base.rb', line 29

def self.human_attribute_name(attr, _options = {})
  attr
end

.lookup_ancestorsObject



33
34
35
# File 'lib/itsf/services/v2/response/base.rb', line 33

def self.lookup_ancestors
  [self]
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/itsf/services/v2/response/base.rb', line 21

def failed?
  !success?
end

#read_attribute_for_validation(attr) ⇒ Object



25
26
27
# File 'lib/itsf/services/v2/response/base.rb', line 25

def read_attribute_for_validation(attr)
  send(attr)
end

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/itsf/services/v2/response/base.rb', line 17

def success?
  @errors.blank?
end