Class: PostsFake
- Inherits:
-
Object
- Object
- PostsFake
- Defined in:
- lib/fake.rb
Defined Under Namespace
Classes: Fake
Instance Attribute Summary (collapse)
-
- (Object) people_hash
readonly
Returns the value of attribute people_hash.
-
- (Object) post_fakes
readonly
Returns the value of attribute post_fakes.
Instance Method Summary (collapse)
-
- (PostsFake) initialize(posts)
constructor
A new instance of PostsFake.
- - (Object) models
Constructor Details
- (PostsFake) initialize(posts)
A new instance of PostsFake
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fake.rb', line 5 def initialize(posts) = [] posts.each do |p| << p. p.comments.each do |c| << c. end end people = Person.where(:id => ).includes(:profile) @people_hash = {} people.each{|person| @people_hash[person.id] = person} @post_fakes = posts.map do |post| f = Fake.new(post, self) f.comments = post.comments.map do |comment| Fake.new(comment, self) end f end end |
Instance Attribute Details
- (Object) people_hash (readonly)
Returns the value of attribute people_hash
2 3 4 |
# File 'lib/fake.rb', line 2 def people_hash @people_hash end |
- (Object) post_fakes (readonly)
Returns the value of attribute post_fakes
2 3 4 |
# File 'lib/fake.rb', line 2 def post_fakes @post_fakes end |
Instance Method Details
- (Object) models
27 28 29 |
# File 'lib/fake.rb', line 27 def models self.post_fakes.map{|a| a.model } end |