Module: SocialStream::ActivityStreams
- Defined in:
- lib/social_stream/activity_streams.rb,
lib/social_stream/base/autoload.rb,
lib/social_stream/activity_streams/subtype.rb,
lib/social_stream/activity_streams/supertype.rb
Overview
Maintains a list of the equivalences between SocialStream’s models and ActivityStreams’ object types
activitystrea.ms/specs/json/schema/activity-schema.html#object-types
Defined Under Namespace
Constant Summary collapse
- DEFAULT_TYPE =
:note
- @@register =
{}
Class Method Summary collapse
-
.model(type) ⇒ Object
Get the SocialStream’s model, given a ActivityStreams’ object type.
-
.model!(type) ⇒ Object
Get the SocialStream’s model, given a ActivityStreams’ object type or the default model.
-
.register(object_type, klass = nil) ⇒ Object
Register a new ActivityStreams type along with the model.
-
.type(klass) ⇒ Object
Get the ActivityStreams’ object type, given a SocialStream’s model.
Class Method Details
.model(type) ⇒ Object
Get the SocialStream’s model, given a ActivityStreams’ object type
20 21 22 23 |
# File 'lib/social_stream/activity_streams.rb', line 20 def model(type) model = @@register[type] model && model.to_s.classify.constantize end |
.model!(type) ⇒ Object
Get the SocialStream’s model, given a ActivityStreams’ object type or the default model
27 28 29 |
# File 'lib/social_stream/activity_streams.rb', line 27 def model!(type) model(type) || model(SocialStream::ActivityStreams::DEFAULT_TYPE) end |
.register(object_type, klass = nil) ⇒ Object
Register a new ActivityStreams type along with the model
13 14 15 16 17 |
# File 'lib/social_stream/activity_streams.rb', line 13 def register(object_type, klass = nil) klass ||= object_type @@register[object_type] = klass end |
.type(klass) ⇒ Object
Get the ActivityStreams’ object type, given a SocialStream’s model
32 33 34 35 36 |
# File 'lib/social_stream/activity_streams.rb', line 32 def type(klass) klass = klass.to_s.underscore.to_sym unless klass.is_a?(Symbol) @@register.invert[klass] end |