Class: Apitizer::Routing::Path
- Inherits:
-
Object
- Object
- Apitizer::Routing::Path
- Defined in:
- lib/apitizer/routing/path.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #address ⇒ Object
- #advance(step, options) ⇒ Object
- #clone ⇒ Object
-
#initialize(options = {}) ⇒ Path
constructor
A new instance of Path.
- #on?(on) ⇒ Boolean
- #permit?(action) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Path
Returns a new instance of Path.
6 7 8 9 |
# File 'lib/apitizer/routing/path.rb', line 6 def initialize( = {}) @steps = [:steps] || [] @node = [:node] end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/apitizer/routing/path.rb', line 4 def node @node end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
4 5 6 |
# File 'lib/apitizer/routing/path.rb', line 4 def steps @steps end |
Instance Method Details
#address ⇒ Object
11 12 13 |
# File 'lib/apitizer/routing/path.rb', line 11 def address @steps.map(&:to_s).join('/') end |
#advance(step, options) ⇒ Object
15 16 17 18 19 |
# File 'lib/apitizer/routing/path.rb', line 15 def advance(step, ) @steps << step @node = .fetch(:node) @on = [:on] end |
#clone ⇒ Object
29 30 31 |
# File 'lib/apitizer/routing/path.rb', line 29 def clone self.class.new(steps: @steps.clone, node: @node) end |
#on?(on) ⇒ Boolean
25 26 27 |
# File 'lib/apitizer/routing/path.rb', line 25 def on?(on) @on == on end |
#permit?(action) ⇒ Boolean
21 22 23 |
# File 'lib/apitizer/routing/path.rb', line 21 def permit?(action) @node && @node.permit?(action, on: @on) end |