Module: KRPC::Streaming::StreamConstructors
Defined Under Namespace
Modules: ClassMethods
Constant Summary
collapse
- STREAM_METHOD_SUFFIX =
"_stream"
- STREAM_METHOD_REGEX =
/^(.+)(?:#{STREAM_METHOD_SUFFIX})$/
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, **kwargs, &block) ⇒ Object
160
161
162
163
164
165
166
167
168
|
# File 'lib/krpc/streaming.rb', line 160
def method_missing(method, *args, **kwargs, &block)
if STREAM_METHOD_REGEX =~ method.to_s
if respond_to? $1.to_sym
ctors = self.is_a?(Module) ? stream_constructors : self.class.stream_constructors
return ctors[$1].call(self, *args, **kwargs) if ctors.include? $1
end
end
super
end
|
Class Method Details
.included(base) ⇒ Object
155
156
157
158
|
# File 'lib/krpc/streaming.rb', line 155
def self.included(base)
base.extend ClassMethods
base.extend self
end
|
Instance Method Details
#respond_to_missing?(method) ⇒ Boolean
170
171
172
173
174
175
176
177
178
|
# File 'lib/krpc/streaming.rb', line 170
def respond_to_missing?(method, *)
if STREAM_METHOD_REGEX =~ method.to_s
if respond_to? $1.to_sym
ctors = self.is_a?(Module) ? stream_constructors : self.class.stream_constructors
return true if ctors.include? $1
end
end
super
end
|