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
Class Method Details
.children ⇒ Object
11 12 13 |
# File 'lib/thrift_rack/server.rb', line 11 def children @children ||= [] end |
.inherited(subclass) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/thrift_rack/server.rb', line 4 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
15 16 17 18 |
# File 'lib/thrift_rack/server.rb', line 15 def inspect return super if self == ThriftRack::Server "#{self.name}(processor_class=#{self.processor_class},mount_path=#{self.mount_path})" end |
.mount_path ⇒ Object
33 34 35 36 37 |
# File 'lib/thrift_rack/server.rb', line 33 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
20 21 22 23 24 25 26 27 |
# File 'lib/thrift_rack/server.rb', line 20 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.class}" end end |
.protocol_factory ⇒ Object
29 30 31 |
# File 'lib/thrift_rack/server.rb', line 29 def protocol_factory Thrift::CompactProtocolFactory.new end |
.thrift_namespace ⇒ Object
39 40 41 |
# File 'lib/thrift_rack/server.rb', line 39 def thrift_namespace @thrift_namespace ||= self.name.scan(/[^\:]+$/).first.to_s.gsub(/Server$/, "").freeze end |