Class: ApiResource::ResourceCollection
- Inherits:
-
Object
- Object
- ApiResource::ResourceCollection
show all
- Includes:
- Enumerable
- Defined in:
- lib/api-resource/resource.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ResourceCollection.
310
311
312
313
|
# File 'lib/api-resource/resource.rb', line 310
def initialize(data, meta, klass)
meta.each { |k, v| self.class.class_eval { define_method(k) { v } } } if meta
@resources = data.map { |e| klass.new(e) }.to_a
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
315
316
317
318
319
320
321
|
# File 'lib/api-resource/resource.rb', line 315
def method_missing(m, *args, &block)
if @resources.respond_to?(m)
@resources.send(m,*args, &block)
else
super
end
end
|
Instance Method Details
#acts_like_array? ⇒ Boolean
327
328
|
# File 'lib/api-resource/resource.rb', line 327
def acts_like_array?
end
|
#respond_to_missing?(m, _) ⇒ Boolean
323
324
325
|
# File 'lib/api-resource/resource.rb', line 323
def respond_to_missing?(m, _)
@resources.respond_to?(m)
end
|