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



101
102
103
# File 'lib/code42/attribute_serializer.rb', line 101

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

Instance Method Details

#<<(exception) ⇒ Object



105
106
107
# File 'lib/code42/attribute_serializer.rb', line 105

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

#each(&block) ⇒ Object



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

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

#from(value) ⇒ Object



109
110
111
# File 'lib/code42/attribute_serializer.rb', line 109

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

#to(value) ⇒ Object



113
114
115
# File 'lib/code42/attribute_serializer.rb', line 113

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