Class: Pastvu::Comment

Inherits:
Model
  • Object
show all
Defined in:
lib/pastvu/comment/comment.rb

Instance Method Summary collapse

Methods inherited from Model

#initialize, #to_json

Constructor Details

This class inherits a constructor from Pastvu::Model

Instance Method Details

#repliesObject



3
4
5
6
# File 'lib/pastvu/comment/comment.rb', line 3

def replies
  populate_replies unless @comments.nil?
  @replies ||= []
end

#replies=(value) ⇒ Object



8
9
10
# File 'lib/pastvu/comment/comment.rb', line 8

def replies=(value)
  @replies = value
end

#to_hashObject



12
13
14
15
16
17
18
19
# File 'lib/pastvu/comment/comment.rb', line 12

def to_hash
  instance_variables.each_with_object({}) do |var, object|
    next if var == :@replies

    var = var[1..-1]
    object[camelize(var).to_sym] = method(var).call
  end
end