Class: RailsTwirp::Mapper
- Inherits:
-
Object
- Object
- RailsTwirp::Mapper
- Defined in:
- lib/rails_twirp/mapper.rb
Instance Method Summary collapse
-
#initialize(route_set) ⇒ Mapper
constructor
A new instance of Mapper.
- #scope(**options) ⇒ Object
- #service(service_definition, **kwargs, &block) ⇒ Object
Constructor Details
#initialize(route_set) ⇒ Mapper
Returns a new instance of Mapper.
57 58 59 60 |
# File 'lib/rails_twirp/mapper.rb', line 57 def initialize(route_set) @route_set = route_set @module = nil end |
Instance Method Details
#scope(**options) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rails_twirp/mapper.rb', line 68 def scope(**) last_module = @module if (modyoule = .delete(:module)) @module = @module.nil? ? modyoule : "#{@module}/#{modyoule}" end raise ArgumentError, "Unknown scope argument #{.keys.first}" unless .empty? yield ensure @module = last_module end |
#service(service_definition, **kwargs, &block) ⇒ Object
62 63 64 65 66 |
# File 'lib/rails_twirp/mapper.rb', line 62 def service(service_definition, **kwargs, &block) service_route_set = @route_set.services[service_definition] service_mapper = ServiceMapper.new(service_route_set, self) scope(**kwargs) { service_mapper.instance_exec(&block) } end |