Class: ActivityStreams::Activity
Instance Method Summary
collapse
included
Methods inherited from Base
#as_json
Methods included from Validator
#to_float, #to_integer, #to_iri, #to_time, #validate_attribute!
Constructor Details
#initialize(attributes = {}) ⇒ Activity
Returns a new instance of Activity.
21
22
23
24
|
# File 'lib/activitystreams/activity.rb', line 21
def initialize(attributes = {})
attributes[:verb] ||= Verb.new
super
end
|
Instance Method Details
#recommended_verb? ⇒ Boolean
44
45
46
47
|
# File 'lib/activitystreams/activity.rb', line 44
def recommended_verb?
recommended_verbs.blank? ||
recommended_verbs.include?(verb.to_s)
end
|
#recommended_verbs ⇒ Object
49
50
51
|
# File 'lib/activitystreams/activity.rb', line 49
def recommended_verbs
(object.try(:recommended_verbs) || []).collect(&:to_s)
end
|
#validate_attributes! ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/activitystreams/activity.rb', line 26
def validate_attributes!
super
[:id, :url].each do |_attr_|
to_iri _attr_
end
[:published, :updated].each do |_attr_|
to_time _attr_
end
[:actor, :object, :target, :provider, :generator].each do |_attr_|
validate_attribute! _attr_, Object
end
validate_attribute! :verb, Verb
validate_attribute! :icon, MediaLink
unless recommended_verb?
ActivityStreams.logger.warn "\"#{verb.to_s}\" is not recommended. \"#{recommended_verbs.join('", "')}\" are recommended."
end
end
|