module ActivityStreams::Concerns::Serialization

Attributes

unsupported_context[RW]
unsupported_properties[RW]

Public Instance Methods

to_h() click to toggle source
# 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) click to toggle source
# File lib/activity_streams/concerns/serialization.rb, line 9
def to_json(*args)
  JSON.dump(to_h)
end