Module: GroupDocs::Extensions::Lookup
- Included in:
- Document, Storage::File, Storage::Folder
- Defined in:
- lib/groupdocs/extensions/lookup.rb
Overview
Extends classes providing them with .find! and .find_all! class methods which is a bit of sugar for working with files, folder and documents,
It’s not that flexible because requires extending class to implement .all! class method.
This module is a subject to modifications.
Instance Method Summary collapse
-
#find!(attribute, value, access = {}) ⇒ GroupDocs::Api::Entity
Returns first object matching given options.
-
#find_all!(attribute, value, access = {}) ⇒ Array
Returns all objects matching given options.
Instance Method Details
#find!(attribute, value, access = {}) ⇒ GroupDocs::Api::Entity
Returns first object matching given options.
24 25 26 |
# File 'lib/groupdocs/extensions/lookup.rb', line 24 def find!(attribute, value, access = {}) find_all!(attribute, value, access).first end |
#find_all!(attribute, value, access = {}) ⇒ Array
Returns all objects matching given options.
Each entity has to implement #all! method for this to work.
42 43 44 45 46 47 48 |
# File 'lib/groupdocs/extensions/lookup.rb', line 42 def find_all!(attribute, value, access = {}) respond_to?(:all!) or raise NoMethodError, "#{self}.all! is not implemented - aborting." all!('/', access).select do |object| value === object.send(attribute) end end |