Class: RailsTwirp::RouteSet

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_twirp/route_set.rb

Defined Under Namespace

Classes: ServiceRouteSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRouteSet

Returns a new instance of RouteSet.



11
12
13
14
15
16
# File 'lib/rails_twirp/route_set.rb', line 11

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

#servicesObject (readonly)

Returns the value of attribute services.



9
10
11
# File 'lib/rails_twirp/route_set.rb', line 9

def services
  @services
end

Instance Method Details

#draw(&block) ⇒ Object



18
19
20
21
# File 'lib/rails_twirp/route_set.rb', line 18

def draw(&block)
  mapper = Mapper.new(self)
  mapper.instance_exec(&block)
end

#to_servicesObject



23
24
25
# File 'lib/rails_twirp/route_set.rb', line 23

def to_services
  services.each_value.map(&:to_service)
end