Class: Relaxo::Model::Key
- Inherits:
-
Struct
- Object
- Struct
- Relaxo::Model::Key
- Defined in:
- lib/relaxo/model/base.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
- #object_path(model, **arguments) ⇒ Object
- #prefix_path(model, **arguments) ⇒ Object
- #resolve(key_path, model, **arguments) ⇒ Object
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index
26 27 28 |
# File 'lib/relaxo/model/base.rb', line 26 def index @index end |
#prefix ⇒ Object
Returns the value of attribute prefix
26 27 28 |
# File 'lib/relaxo/model/base.rb', line 26 def prefix @prefix end |
Instance Method Details
#object_path(model, **arguments) ⇒ Object
42 43 44 |
# File 'lib/relaxo/model/base.rb', line 42 def object_path(model, **arguments) resolve(self.prefix + self.index, model, **arguments).join('/') end |
#prefix_path(model, **arguments) ⇒ Object
46 47 48 |
# File 'lib/relaxo/model/base.rb', line 46 def prefix_path(model, **arguments) resolve(self.prefix, model, **arguments).join('/') end |
#resolve(key_path, model, **arguments) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/relaxo/model/base.rb', line 27 def resolve(key_path, model, **arguments) key_path.collect do |component| case component when Symbol arguments[component] || model.send(component) || 'null' when Array resolve(component, model, arguments).join('-') when Proc model.instance_exec(**arguments, &component) else component end end end |