Module: Vedeu::DSL::Use
Overview
Provides helper methods for building views.
Instance Method Summary collapse
-
#duplicate(name) ⇒ void
Duplicate a stored model.
-
#use(name) ⇒ void
Use the attribute of stored model.
Instance Method Details
#duplicate(name) ⇒ void
-
Only models of the same repository can be used in this way.
-
If the stored model cannot be found, the duplicate may not have the values you required.
-
Values defined before will be overwritten by the new values from the stored model.
-
Values defined after will overwrite the values of the new duplicate model.
This method returns an undefined value.
Duplicate a stored model.
This DSL method copies the attributes of a stored model, changes the name to that of the current model, and stores the duplicate as a new model in model’s repository.
33 34 35 36 37 |
# File 'lib/vedeu/dsl/shared/use.rb', line 33 def duplicate(name) duplicated = model.repository.by_name(name).dup duplicated.name = model.name duplicated.store end |
#use(name) ⇒ void
-
Only models of the same repository can be used in this way.
-
If the stored model cannot be found, a ModelNotFound exception may be raised, or the request for an attribute may raise a NoMethodError exception.
This method returns an undefined value.
Use the attribute of stored model.
This DSL method provides access to a stored model by name. You can then request an attribute of that model for use within the current model.
63 64 65 |
# File 'lib/vedeu/dsl/shared/use.rb', line 63 def use(name) model.repository.by_name(name) end |