Module: Mongoo::GridFs::DescribeDsl
- Included in:
- DescribeDsl
- Defined in:
- lib/mongoo/grid_fs/describe_dsl.rb
Instance Method Summary collapse
- #define_grid_fs_file_method(name, opts) ⇒ Object
-
#define_grid_fs_files_method(name, opts) ⇒ Object
define_grid_fs_file_methods.
- #grid_fs_file(name, opts = {}) ⇒ Object
- #grid_fs_files(name, opts = {}) ⇒ Object
Instance Method Details
#define_grid_fs_file_method(name, opts) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mongoo/grid_fs/describe_dsl.rb', line 12 def define_grid_fs_file_method(name, opts) attribute(name, :type => :hash, :define_methods => false) blk = Proc.new { if file = instance_variable_get("@#{name}") file else db_lambda = opts[:db] || lambda { self.db } container = get_or_set(name, {}) file = Mongoo::GridFs::File.new(container, db_lambda) instance_variable_set("@#{name}", file) end } @klass.send(:define_method, name, &blk) end |
#define_grid_fs_files_method(name, opts) ⇒ Object
define_grid_fs_file_methods
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mongoo/grid_fs/describe_dsl.rb', line 28 def define_grid_fs_files_method(name, opts) attribute(name, :type => :hash, :define_methods => false) blk = Proc.new { if files = instance_variable_get("@#{name}") files else db_lambda = opts[:db] || lambda { self.db } container = get_or_set(name, {}) files = Mongoo::GridFs::Files.new(container, db_lambda) instance_variable_set("@#{name}", files) end } @klass.send(:define_method, name, &blk) end |
#grid_fs_file(name, opts = {}) ⇒ Object
4 5 6 |
# File 'lib/mongoo/grid_fs/describe_dsl.rb', line 4 def grid_fs_file(name, opts={}) define_grid_fs_file_method(name, opts) end |
#grid_fs_files(name, opts = {}) ⇒ Object
8 9 10 |
# File 'lib/mongoo/grid_fs/describe_dsl.rb', line 8 def grid_fs_files(name, opts={}) define_grid_fs_files_method(name, opts) end |