Class: Administer::Model
- Inherits:
-
Object
- Object
- Administer::Model
- Includes:
- Fields
- Defined in:
- lib/administer/model.rb
Constant Summary collapse
- @@models =
[]
Instance Attribute Summary collapse
-
#entity ⇒ Object
Returns the value of attribute entity.
Class Method Summary collapse
Instance Method Summary collapse
- #display_name(object) ⇒ Object
-
#initialize(model_class) ⇒ Model
constructor
A new instance of Model.
Methods included from Fields
Constructor Details
#initialize(model_class) ⇒ Model
Returns a new instance of Model.
33 34 35 36 |
# File 'lib/administer/model.rb', line 33 def initialize(model_class) @entity = model_class @config = Administer::Config.for(@entity) end |
Instance Attribute Details
#entity ⇒ Object
Returns the value of attribute entity.
31 32 33 |
# File 'lib/administer/model.rb', line 31 def entity @entity end |
Class Method Details
.all ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/administer/model.rb', line 8 def all if @@models.empty? Rails.application.paths.app.models.paths.each do |models_path| Dir[File.("**/*.rb", models_path)].each do |path| model_name = path.split('/').last.gsub(/\.rb$/, '') @@models << Administer::Model.for(model_name) end end end @@models end |
Instance Method Details
#display_name(object) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/administer/model.rb', line 38 def display_name(object) display_function = @config.display_name if display_function.is_a? Symbol return object.send(display_function) else return object.instance_eval(&display_function) end end |