Module: ActivityStreams::Concerns::Serialization
- Included in:
- Model
- Defined in:
- lib/activity_streams/concerns/serialization.rb
Instance Attribute Summary collapse
-
#unsupported_context ⇒ Object
Returns the value of attribute unsupported_context.
-
#unsupported_properties ⇒ Object
Returns the value of attribute unsupported_properties.
Instance Method Summary collapse
Instance Attribute Details
#unsupported_context ⇒ Object
Returns the value of attribute unsupported_context.
6 7 8 |
# File 'lib/activity_streams/concerns/serialization.rb', line 6 def unsupported_context @unsupported_context end |
#unsupported_properties ⇒ Object
Returns the value of attribute unsupported_properties.
7 8 9 |
# File 'lib/activity_streams/concerns/serialization.rb', line 7 def unsupported_properties @unsupported_properties end |
Instance Method Details
#to_h ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/activity_streams/concerns/serialization.rb', line 13 def to_h attrs = attributes.dup if unsupported_properties attrs.merge!(unsupported_properties) end attrs = self.is_a?(ActivityStreams::Activity::Update) ? attrs : attrs.compact attrs.transform_values do |v| case v when ActivityStreams::Model then v.to_h when Date, Time then v.iso8601 else v end end end |
#to_json(*args) ⇒ Object
9 10 11 |
# File 'lib/activity_streams/concerns/serialization.rb', line 9 def to_json(*args) JSON.dump(to_h) end |