Class: Baza::DatabaseModel
- Inherits:
-
Object
- Object
- Baza::DatabaseModel
- Defined in:
- lib/baza/database_model.rb
Overview
Used for link-methods in Rails apps
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(instance) ⇒ DatabaseModel
constructor
A new instance of DatabaseModel.
- #model_name ⇒ Object
- #persisted? ⇒ Boolean
- #to_param ⇒ Object
Constructor Details
#initialize(instance) ⇒ DatabaseModel
Returns a new instance of DatabaseModel.
3 4 5 |
# File 'lib/baza/database_model.rb', line 3 def initialize(instance) @instance = instance end |
Instance Method Details
#id ⇒ Object
23 24 25 |
# File 'lib/baza/database_model.rb', line 23 def id @instance.name end |
#model_name ⇒ Object
7 8 9 |
# File 'lib/baza/database_model.rb', line 7 def model_name Baza::DatabaseModelName.new(@instance) end |
#persisted? ⇒ Boolean
11 12 13 |
# File 'lib/baza/database_model.rb', line 11 def persisted? true end |
#to_param ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/baza/database_model.rb', line 15 def to_param if @instance.respond_to?(:to_param) @instance.try(:to_param) else @instance.name end end |