Class: BrocadeVRouter::PathBuilder
- Inherits:
-
Object
- Object
- BrocadeVRouter::PathBuilder
- Defined in:
- lib/brocade_vrouter/path_builder.rb
Constant Summary collapse
- SEPARATOR =
'/'.freeze
- SNAKE_TRANSFORM =
['_'.freeze, '-'.freeze].freeze
- WHTSP_TRANSFORM =
[' '.freeze, SEPARATOR].freeze
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
Instance Method Summary collapse
-
#initialize(context = nil, base_path = nil, &blk) ⇒ PathBuilder
constructor
A new instance of PathBuilder.
- #to_a ⇒ Object
Constructor Details
#initialize(context = nil, base_path = nil, &blk) ⇒ PathBuilder
Returns a new instance of PathBuilder.
9 10 11 12 13 14 15 16 |
# File 'lib/brocade_vrouter/path_builder.rb', line 9 def initialize(context = nil, base_path = nil, &blk) @base_path, @paths, @context = base_path, [], context if block_given? @context ||= eval 'self', blk.binding instance_eval(&blk) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &blk) ⇒ Object (private)
40 41 42 43 44 |
# File 'lib/brocade_vrouter/path_builder.rb', line 40 def method_missing(*args, &blk) return @context.send(*args) if @context.respond_to?(args.first, true) @paths << generate_paths!(*args, &blk) @paths.last end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
7 8 9 |
# File 'lib/brocade_vrouter/path_builder.rb', line 7 def base_path @base_path end |
Instance Method Details
#to_a ⇒ Object
18 19 20 21 |
# File 'lib/brocade_vrouter/path_builder.rb', line 18 def to_a return @paths.flatten if !base_path || base_path.empty? @paths.flatten.map { |p| [base_path, p].join(SEPARATOR) } end |