Class: Brainstem::TestHelpers::BrainstemDataHelper::BrainstemHelperCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/brainstem/test_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ BrainstemHelperCollection

Returns a new instance of BrainstemHelperCollection.



47
48
49
50
51
# File 'lib/brainstem/test_helpers.rb', line 47

def initialize(collection)
  collection.each do |item|
    self << BrainstemHelperItem.new(item)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



61
62
63
# File 'lib/brainstem/test_helpers.rb', line 61

def method_missing(name)
  map { |item| item.send(name.to_s.singularize) }
end

Instance Method Details

#by_id(id) ⇒ Object



57
58
59
# File 'lib/brainstem/test_helpers.rb', line 57

def by_id(id)
  detect { |item| item.id == id.to_s }
end

#idsObject



53
54
55
# File 'lib/brainstem/test_helpers.rb', line 53

def ids
  map { |item| item.id.to_i }
end