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



90
91
92
93
94
95
96
97
98
# File 'lib/social_stream/models/subject.rb', line 90

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



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

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

#respond_to?(*args) ⇒ Boolean

Actor handles some methods

Returns:

  • (Boolean)


101
102
103
# File 'lib/social_stream/models/subject.rb', line 101

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

#to_paramObject



85
86
87
# File 'lib/social_stream/models/subject.rb', line 85

def to_param
  slug
end