Sha256: 5a96ad45dd7b2f5d335ed159e973cb4f5259288bf1a0548fa562c8c959424a56

Contents?: true

Size: 361 Bytes

Versions: 15

Compression:

Stored size: 361 Bytes

Contents

class Post
  include ActiveModel::Model

  attr_accessor :id, :title, :body

  POSTS = [
    {id: 1, title: 'Title One', body: 'Body One'},
    {id: 2, title: 'Title Two', body: 'Body Two'}
  ]

  def self.all
    POSTS.map {|attrs| new(attrs) }
  end
  
  def self.find(id)
    all.detect {|post| post.id == id.to_i }
  end
  
  def to_param
    id
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
lockup-1.7.1 spec/dummy/app/models/post.rb
lockup-1.7 spec/dummy/app/models/post.rb
lockup-1.6.1 spec/dummy/app/models/post.rb
lockup-1.6 spec/dummy/app/models/post.rb
lockup-1.5.1 spec/dummy/app/models/post.rb
lockup-1.5 spec/dummy/app/models/post.rb
lockup-1.4.5.1 spec/dummy/app/models/post.rb
lockup-1.4.4 spec/dummy/app/models/post.rb
lockup-1.4.3 spec/dummy/app/models/post.rb
lockup-1.4.2 spec/dummy/app/models/post.rb
lockup-1.4.1 spec/dummy/app/models/post.rb
lockup-1.4 spec/dummy/app/models/post.rb
lockup-1.3.2.1 spec/dummy/app/models/post.rb
lockup-1.3.2 spec/dummy/app/models/post.rb
lockup-1.3.1 spec/dummy/app/models/post.rb