Class: Mappable::MapRoute
- Inherits:
-
Object
- Object
- Mappable::MapRoute
- Defined in:
- lib/mappable/map_route.rb
Instance Attribute Summary collapse
-
#in_value ⇒ Object
readonly
Returns the value of attribute in_value.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
Instance Method Summary collapse
-
#initialize(map, in_value) ⇒ MapRoute
constructor
A new instance of MapRoute.
- #map_route_method?(sym) ⇒ Boolean
- #mapped_value_for_method_missing(sym) ⇒ Object
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(map, in_value) ⇒ MapRoute
Returns a new instance of MapRoute.
5 6 7 8 |
# File 'lib/mappable/map_route.rb', line 5 def initialize(map, in_value) @map = map @in_value = in_value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/mappable/map_route.rb', line 19 def method_missing(sym, *args, &block) if map_route_method?(sym) mapped_value_for_method_missing(sym) else super(sym, *args, &block) end end |
Instance Attribute Details
#in_value ⇒ Object (readonly)
Returns the value of attribute in_value.
3 4 5 |
# File 'lib/mappable/map_route.rb', line 3 def in_value @in_value end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
3 4 5 |
# File 'lib/mappable/map_route.rb', line 3 def map @map end |
Instance Method Details
#map_route_method?(sym) ⇒ Boolean
15 16 17 |
# File 'lib/mappable/map_route.rb', line 15 def map_route_method?(sym) sym.to_s.starts_with?('to_') end |
#mapped_value_for_method_missing(sym) ⇒ Object
10 11 12 13 |
# File 'lib/mappable/map_route.rb', line 10 def mapped_value_for_method_missing(sym) mapping_name = sym.to_s.slice(3..-1).to_sym map.value_for(mapping_name, in_value) end |