Class: UrlMount::Segment::Variable

Inherits:
Base
  • Object
show all
Defined in:
lib/url_mount.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#optional_variable_segments

Constructor Details

#initialize(name, options) ⇒ Variable

Returns a new instance of Variable.



166
167
168
# File 'lib/url_mount.rb', line 166

def initialize(name, options)
  @name, @options = name.to_sym, (options || {})
end

Instance Method Details

#required_variable_segmentsObject



170
171
172
# File 'lib/url_mount.rb', line 170

def required_variable_segments
  [self]
end

#to_s(opts = {}) ⇒ Object



174
175
176
177
# File 'lib/url_mount.rb', line 174

def to_s(opts = {})
  item = opts.delete(name) || @options[name]
  item.respond_to?(:call) ? item.call : item
end