Class: RailsTwirp::RouteSet
- Inherits:
-
Object
- Object
- RailsTwirp::RouteSet
- Defined in:
- lib/rails_twirp/route_set.rb
Defined Under Namespace
Classes: ServiceRouteSet
Instance Attribute Summary collapse
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #draw(&block) ⇒ Object
-
#initialize ⇒ RouteSet
constructor
A new instance of RouteSet.
- #to_services ⇒ Object
Constructor Details
#initialize ⇒ RouteSet
Returns a new instance of RouteSet.
13 14 15 16 17 18 |
# File 'lib/rails_twirp/route_set.rb', line 13 def initialize # Make services a hash with a default_proc, so the same class gets reused if the service # method is used multiple times with the same key. # This makes it possible to split up the routes into multiple files. @services = Hash.new { |hash, key| hash[key] = ServiceRouteSet.new(key) } end |
Instance Attribute Details
#services ⇒ Object (readonly)
Returns the value of attribute services.
11 12 13 |
# File 'lib/rails_twirp/route_set.rb', line 11 def services @services end |
Instance Method Details
#draw(&block) ⇒ Object
20 21 22 23 |
# File 'lib/rails_twirp/route_set.rb', line 20 def draw(&block) mapper = Mapper.new(self) mapper.instance_exec(&block) end |
#to_services ⇒ Object
25 26 27 |
# File 'lib/rails_twirp/route_set.rb', line 25 def to_services services.each_value.map(&:to_service) end |