Class: TentD::Model::PostVersion
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from UserScoped
included
included, #type, #type=
#assign_permissions, included, #permissions_json
Class Method Details
.public_attributes ⇒ Object
35
36
37
|
# File 'lib/tentd/model/post_version.rb', line 35
def self.public_attributes
Post.public_attributes
end
|
Instance Method Details
#as_json(options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/tentd/model/post_version.rb', line 39
def as_json(options = {})
attributes = super
post_attrs = post.as_json(options)
attributes[:type] = type.uri
attributes[:version] = version
attributes[:app] = { :url => attributes.delete(:app_url), :name => attributes.delete(:app_name) }
attributes[:mentions] = mentions.map do |mention|
h = { :entity => mention.entity }
h[:post] = mention.mentioned_post_id if mention.mentioned_post_id
h
end
if options[:app]
attributes[:following_id] = following.public_id if following
end
attributes[:permissions] = post_attrs[:permissions]
Array(options[:exclude]).each { |k| attributes.delete(k) if k }
attributes
end
|