Class: Mongoo::DescribeDsl

Inherits:
Object
  • Object
show all
Includes:
Attributes::DescribeDsl, Embedded::DescribeDsl, GridFs::DescribeDsl
Defined in:
lib/mongoo/grid_fs/describe_dsl.rb,
lib/mongoo/describe_dsl.rb,
lib/mongoo/embedded/describe_dsl.rb,
lib/mongoo/attributes/describe_dsl.rb

Overview

Mongoo

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Attributes::DescribeDsl

#attribute

Methods included from Embedded::DescribeDsl

#embeds_many, #embeds_one

Methods included from GridFs::DescribeDsl

#define_grid_fs_file_method, #define_grid_fs_files_method, #grid_fs_file, #grid_fs_files

Constructor Details

#initialize(klass) ⇒ DescribeDsl

Returns a new instance of DescribeDsl.



11
12
13
# File 'lib/mongoo/describe_dsl.rb', line 11

def initialize(klass)
  @klass = klass
end

Class Method Details

.after_describeObject



3
4
5
# File 'lib/mongoo/describe_dsl.rb', line 3

def self.after_describe
  @after_describe ||= []
end

.before_describeObject



7
8
9
# File 'lib/mongoo/describe_dsl.rb', line 7

def self.before_describe
  @before_describe ||= []
end

Instance Method Details

#describe(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mongoo/describe_dsl.rb', line 15

def describe(&block)
  Mutex.new.synchronize do
    self.class.before_describe.uniq!
    self.class.after_describe.uniq!

    self.class.before_describe.each do |m|
      send(m)
    end

    block.call(self)

    self.class.after_describe.each do |m|
      send(m)
    end
  end
end

#index(*args) ⇒ Object



32
33
34
# File 'lib/mongoo/describe_dsl.rb', line 32

def index(*args)
  @klass.send(:index, *args)
end