Class: LieutenantGovernor::Routing::Extractor
- Inherits:
-
Object
- Object
- LieutenantGovernor::Routing::Extractor
- Defined in:
- lib/lieutenant_governor/routing/extractor.rb
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Class Method Summary collapse
-
.extract(routes) ⇒ Hash
Takes applications routes and converts to hash.
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(routes) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize(routes) ⇒ Extractor
Returns a new instance of Extractor.
19 20 21 |
# File 'lib/lieutenant_governor/routing/extractor.rb', line 19 def initialize(routes) @routes = routes end |
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
9 10 11 |
# File 'lib/lieutenant_governor/routing/extractor.rb', line 9 def routes @routes end |
Class Method Details
.extract(routes) ⇒ Hash
Takes applications routes and converts to hash
14 15 16 17 |
# File 'lib/lieutenant_governor/routing/extractor.rb', line 14 def self.extract(routes) instance = new(routes) instance.extract end |
Instance Method Details
#extract ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lieutenant_governor/routing/extractor.rb', line 23 def extract table = {} # possible to get blank strings as keys here routes.reduce(table) do |memo, obj| name = get_name(obj) path = get_path(obj) table[name] = path if name.length > 0 && path.length > 0 end table end |