Module: SocialStream::Models::Subject::InstanceMethods

Defined in:
lib/social_stream/models/subject.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Delegate missing methods to Actor, if they exist there



86
87
88
89
90
91
92
93
94
# File 'lib/social_stream/models/subject.rb', line 86

def method_missing(method, *args, &block)
  super
rescue NameError => subject_error 
  # These methods must be raised to avoid loops (the :actor association calls here again)
  exceptions = [ :_actor_id ]
  raise subject_error if exceptions.include?(method)

  actor!.__send__ method, *args, &block
end

Instance Method Details

#actor!Object



77
78
79
# File 'lib/social_stream/models/subject.rb', line 77

def actor!
  actor || build_actor(:subject_type => self.class.to_s)
end

#respond_to?(*args) ⇒ Boolean

Actor handles some methods

Returns:

  • (Boolean)


97
98
99
# File 'lib/social_stream/models/subject.rb', line 97

def respond_to? *args
  super || actor!.respond_to?(*args)
end

#to_paramObject



81
82
83
# File 'lib/social_stream/models/subject.rb', line 81

def to_param
  slug
end