Module: DocumentFile::ClassMethods
- Defined in:
- lib/document_file.rb
Constant Summary
collapse
- @@documents =
nil
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
84
85
86
|
# File 'lib/document_file.rb', line 84
def method_missing(method_name, *args)
all.respond_to?(method_name) ? self.all.send(method_name, *args) : super
end
|
Instance Method Details
#all(options = {}) ⇒ Object
67
68
69
70
71
72
|
# File 'lib/document_file.rb', line 67
def all(options = {})
offset = options[:offset]
limit = options[:limit]
return @@documents.offset_and_limitize(offset, limit) if @@documents
reload!
end
|
#reload! ⇒ Object
74
75
76
77
78
79
80
81
|
# File 'lib/document_file.rb', line 74
def reload!
if File.directory?(documents_dir)
file_paths = Dir.glob("#{documents_dir}/*.*")
@@documents = Collection.new file_paths.map { |fp| self.new fp }
else
[]
end
end
|