Class: OneOrMany

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/presenters/one_or_many.rb

Instance Method Summary collapse

Instance Method Details

#map(&block) ⇒ Object



5
6
7
8
9
10
11
# File 'app/presenters/one_or_many.rb', line 5

def map(&block)
  if __getobj__.respond_to?(:map)
    __getobj__.map(&block)
  else
    yield __getobj__
  end
end

#select(&block) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/presenters/one_or_many.rb', line 13

def select(&block)
  if __getobj__.respond_to?(:select)
    __getobj__.select(&block)
  else
    return [] unless yield __getobj__
    self
  end
end