Module: ActiveFixture::SearchMethods::ClassMethods

Defined in:
lib/active_fixture/search_methods.rb

Instance Method Summary collapse

Instance Method Details

#allObject



11
12
13
# File 'lib/active_fixture/search_methods.rb', line 11

def all
  fixtures.to_a.map { |fixture| new(fixture) }
end

#find_by(attribute, value) ⇒ Object



19
20
21
# File 'lib/active_fixture/search_methods.rb', line 19

def find_by(attribute, value)
  all.select { |fixture| fixture.send(attribute) == value }
end

#select(id) ⇒ Object



15
16
17
# File 'lib/active_fixture/search_methods.rb', line 15

def select(id)
  all.find { |o| o.id == id } || raise(FixtureNotFound.new(id))
end