Class: ThriftRack::Server
- Inherits:
-
Object
- Object
- ThriftRack::Server
- Defined in:
- lib/thrift_rack/server.rb
Class Method Summary collapse
- .children ⇒ Object
- .inherited(subclass) ⇒ Object
- .inspect ⇒ Object
- .mount_path ⇒ Object
- .processor_class ⇒ Object
- .protocol_factory ⇒ Object
- .thrift_namespace ⇒ Object
Instance Method Summary collapse
-
#initialize(request = nil) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(request = nil) ⇒ Server
3 4 5 |
# File 'lib/thrift_rack/server.rb', line 3 def initialize(request = nil) @_request = request end |
Class Method Details
.children ⇒ Object
15 16 17 |
# File 'lib/thrift_rack/server.rb', line 15 def children @children ||= [] end |
.inherited(subclass) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/thrift_rack/server.rb', line 8 def inherited(subclass) warn "Your class should end with Server not it is #{subclass}" unless subclass.name.end_with?("Server") @children ||= [] @children << subclass super end |
.inspect ⇒ Object
19 20 21 22 |
# File 'lib/thrift_rack/server.rb', line 19 def inspect return super if self == ThriftRack::Server "#{self.name}(processor_class=#{self.processor_class},mount_path=#{self.mount_path})" end |
.mount_path ⇒ Object
37 38 39 40 41 |
# File 'lib/thrift_rack/server.rb', line 37 def mount_path return thrift_namespace unless /^[A-Z]/ =~ thrift_namespace path = thrift_namespace.scan(/[A-Z][a-z]*/).join("_").downcase "/#{path}" end |
.processor_class ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/thrift_rack/server.rb', line 24 def processor_class promissory_class_name = "Thrift::#{thrift_namespace}::#{thrift_namespace}Service::Processor" if Kernel.const_defined?(promissory_class_name) Kernel.const_get(promissory_class_name) else raise "You should overwrite processor_class for #{self}" end end |
.protocol_factory ⇒ Object
33 34 35 |
# File 'lib/thrift_rack/server.rb', line 33 def protocol_factory Thrift::CompactProtocolFactory.new end |
.thrift_namespace ⇒ Object
43 44 45 |
# File 'lib/thrift_rack/server.rb', line 43 def thrift_namespace @thrift_namespace ||= self.name.scan(/[^\:]+$/).first.to_s.gsub(/Server$/, "").freeze end |