Class: ActivityStreams::Object

Inherits:
Base
  • Object
show all
Includes:
ExtProperties
Defined in:
lib/activitystreams/object.rb

Defined Under Namespace

Classes: Article, Audio, Badge, Bookmark, Collection, Comment, Event, File, Group, Image, Note, Person, Place, Product, Question, Review, Service, Video

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExtProperties

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 = {}) ⇒ Object

Returns a new instance of Object.



23
24
25
26
27
28
29
# File 'lib/activitystreams/object.rb', line 23

def initialize(attributes = {})
  _type_ = if self.class.superclass == Object
    self.class.name.demodulize.underscore
  end
  attributes = {:object_type => _type_}.merge(attributes)
  super attributes
end

Class Method Details



52
53
54
55
# File 'lib/activitystreams/object.rb', line 52

def self.recommended_verbs(*verbs)
  @recommended_verbs ||= []
  @recommended_verbs += verbs
end

Instance Method Details



48
49
50
# File 'lib/activitystreams/object.rb', line 48

def recommended_verbs
  self.class.recommended_verbs
end

#validate_attributes!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/activitystreams/object.rb', line 31

def validate_attributes!
  super
  [:id, :object_type, :url].each do |_attr_|
    to_iri _attr_
  end
  [:published, :updated].each do |_attr_|
    to_time _attr_
  end
  validate_attribute! :author, Object
  validate_attribute! :image, MediaLink
  validate_attribute! :attachments, Object, :arrayed!
  [:downstream_duplicates, :upstream_duplicates].each do |_attr_|
    to_iri _attr_, :arrayed!
  end
  # TODO: display_name MUST NOT include HTML
end