Class: Apitizer::Routing::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/apitizer/routing/path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @steps = options[:steps] || []
  @node = options[:node]
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



4
5
6
# File 'lib/apitizer/routing/path.rb', line 4

def node
  @node
end

#stepsObject (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

#addressObject



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, options)
  @steps << step
  @node = options.fetch(:node)
  @on = options[:on]
end

#cloneObject



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

Returns:

  • (Boolean)


25
26
27
# File 'lib/apitizer/routing/path.rb', line 25

def on?(on)
  @on == on
end

#permit?(action) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/apitizer/routing/path.rb', line 21

def permit?(action)
  @node && @node.permit?(action, on: @on)
end