Class: RademadeAdmin::Model::Reflection

Inherits:
Object
  • Object
show all
Defined in:
lib/rademade_admin/model/reflection.rb

Constant Summary collapse

ORM_TYPE_ACTIVERECORD =
'ActiveRecord'
ORM_TYPE_MONGOID =
'Mongoid'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, controller, module_name) ⇒ Reflection

Returns a new instance of Reflection.



11
12
13
# File 'lib/rademade_admin/model/reflection.rb', line 11

def initialize(model, controller, module_name)
  @model, @controller, @module_name = model, controller, module_name
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



9
10
11
# File 'lib/rademade_admin/model/reflection.rb', line 9

def controller
  @controller
end

#modelObject (readonly)

Returns the value of attribute model.



9
10
11
# File 'lib/rademade_admin/model/reflection.rb', line 9

def model
  @model
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



9
10
11
# File 'lib/rademade_admin/model/reflection.rb', line 9

def module_name
  @module_name
end

Instance Method Details

#data_adapterRademadeAdmin::Model::Adapter::Data

Load data adapter for current model



18
19
20
# File 'lib/rademade_admin/model/reflection.rb', line 18

def data_adapter
  @data_adapter ||= "RademadeAdmin::Model::Adapter::Data::#{orm_type}".constantize.new(@model)
end

#hideable?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rademade_admin/model/reflection.rb', line 29

def hideable?
  _model_ancestors.include? RademadeAdmin::Hideable.name
end

#query_adapterRademadeAdmin::Model::Adapter::Query

Load query adapter for current model



25
26
27
# File 'lib/rademade_admin/model/reflection.rb', line 25

def query_adapter
  @query_adapter ||= "RademadeAdmin::Model::Adapter::Query::#{orm_type}".constantize.new(@model)
end