Class: Code42::AttributeSerializerExceptions

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/code42/attribute_serializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(exceptions = []) ⇒ AttributeSerializerExceptions

Returns a new instance of AttributeSerializerExceptions.



103
104
105
# File 'lib/code42/attribute_serializer.rb', line 103

def initialize(exceptions = [])
  @exceptions = exceptions
end

Instance Method Details

#<<(exception) ⇒ Object



107
108
109
# File 'lib/code42/attribute_serializer.rb', line 107

def <<(exception)
  @exceptions << exception
end

#each(&block) ⇒ Object



119
120
121
122
123
124
125
126
127
# File 'lib/code42/attribute_serializer.rb', line 119

def each(&block)
  @exceptions.each do |exception|
    if block_given?
      block.call exception
    else
      yield exception
    end
  end
end

#from(value) ⇒ Object



111
112
113
# File 'lib/code42/attribute_serializer.rb', line 111

def from(value)
  detect { |e| e.from == value }
end

#to(value) ⇒ Object



115
116
117
# File 'lib/code42/attribute_serializer.rb', line 115

def to(value)
  detect { |e| e.to == value }
end