Class: Yrpc::Controllers::Base
- Inherits:
-
Object
- Object
- Yrpc::Controllers::Base
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/yrpc/controllers/base.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
- #call(method_key, &block) ⇒ Object
-
#initialize(method_key:, service:, rpc_desc:, active_call:, message:) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(method_key:, service:, rpc_desc:, active_call:, message:) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 16 17 18 19 |
# File 'lib/yrpc/controllers/base.rb', line 11 def initialize(method_key:, service:, rpc_desc:, active_call:, message:) @request = Request.new( method_key: method_key, service: service, rpc_desc: rpc_desc, active_call: active_call, message: ) end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/yrpc/controllers/base.rb', line 8 def request @request end |
Class Method Details
.after_action(methods) ⇒ Object
27 28 29 30 31 |
# File 'lib/yrpc/controllers/base.rb', line 27 def self.after_action(methods) [*methods].each do |method| set_callback :call, :after, method end end |
.before_action(methods) ⇒ Object
21 22 23 24 25 |
# File 'lib/yrpc/controllers/base.rb', line 21 def self.before_action(methods) [*methods].each do |method| set_callback :call, :before, method end end |
.bind(service_class) ⇒ Object
34 35 36 37 |
# File 'lib/yrpc/controllers/base.rb', line 34 def self.bind(service_class) Yrpc.services << service_class.name.constantize ServiceBinder.new(service_class).bind!(self) end |
Instance Method Details
#call(method_key, &block) ⇒ Object
40 41 42 43 44 |
# File 'lib/yrpc/controllers/base.rb', line 40 def call(method_key, &block) run_callbacks :call do send(method_key, &block) end end |