Class: Rails::Schema::Extractor::Mongoid::ModelAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/schema/extractor/mongoid/model_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ ModelAdapter

Returns a new instance of ModelAdapter.



10
11
12
# File 'lib/rails/schema/extractor/mongoid/model_adapter.rb', line 10

def initialize(model)
  @model = model
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, **kwargs, &block) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rails/schema/extractor/mongoid/model_adapter.rb', line 26

def method_missing(method, *args, **kwargs, &block)
  if model.respond_to?(method)
    model.send(method, *args, **kwargs, &block)
  else
    super
  end
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



8
9
10
# File 'lib/rails/schema/extractor/mongoid/model_adapter.rb', line 8

def model
  @model
end

Instance Method Details

#nameObject



14
15
16
# File 'lib/rails/schema/extractor/mongoid/model_adapter.rb', line 14

def name
  model.name
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rails/schema/extractor/mongoid/model_adapter.rb', line 22

def respond_to_missing?(method, include_private = false)
  model.respond_to?(method, include_private) || super
end

#table_nameObject



18
19
20
# File 'lib/rails/schema/extractor/mongoid/model_adapter.rb', line 18

def table_name
  model.collection_name.to_s
end