Sha256: 62b7677d4f95b9c1569f22680e19aac6a6c3ba997b054526efdb77cdc7a943ce
Contents?: true
Size: 467 Bytes
Versions: 12
Compression:
Stored size: 467 Bytes
Contents
class Author attr_accessor :id, :name FIXTURES = [ { id: 1, name: "Andrew Hite" }, { id: 2, name: "Andrew Latimer" } ] def initialize(attributes = {}) @id = attributes[:id] @name = attributes[:name] end class << self def all FIXTURES.map do |attributes| new(attributes) end end def find(id) attributes = FIXTURES.find { |fixture| fixture[:id] == id.to_i } new(attributes) end end end
Version data entries
12 entries across 12 versions & 1 rubygems