Class: MethodMissingRouter::Route
- Inherits:
-
Object
- Object
- MethodMissingRouter::Route
- Defined in:
- lib/method_missing_router.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #applies_to?(method_name) ⇒ Boolean
-
#initialize(regex, target, options) ⇒ Route
constructor
A new instance of Route.
- #message_for(method_name) ⇒ Object
Constructor Details
#initialize(regex, target, options) ⇒ Route
Returns a new instance of Route.
71 72 73 74 75 |
# File 'lib/method_missing_router.rb', line 71 def initialize(regex, target, ) @regex = regex @target = target @options = end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
69 70 71 |
# File 'lib/method_missing_router.rb', line 69 def target @target end |
Instance Method Details
#applies_to?(method_name) ⇒ Boolean
77 78 79 |
# File 'lib/method_missing_router.rb', line 77 def applies_to?(method_name) @regex =~ method_name end |
#message_for(method_name) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/method_missing_router.rb', line 81 def (method_name) captures = @regex.match(method_name).captures if @options[:pass_matches] return captures elsif @options[:pass_match] return captures.first else return method_name.to_s end end |