Class: Atheme::Service
- Inherits:
-
Object
- Object
- Atheme::Service
- Defined in:
- lib/atheme/service.rb
Instance Attribute Summary collapse
-
#raw_services_output ⇒ Object
readonly
Returns the value of attribute raw_services_output.
Class Method Summary collapse
- .create_service_object(method, service, atheme_data) ⇒ Object
- .inherited(klass) ⇒ Object
- .method_missing(method, *args, &block) ⇒ Object
- .parser_for?(service, command) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(output) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(output) ⇒ Service
Returns a new instance of Service.
4 5 6 |
# File 'lib/atheme/service.rb', line 4 def initialize(output) @raw_services_output = output end |
Instance Attribute Details
#raw_services_output ⇒ Object (readonly)
Returns the value of attribute raw_services_output.
2 3 4 |
# File 'lib/atheme/service.rb', line 2 def raw_services_output @raw_services_output end |
Class Method Details
.create_service_object(method, service, atheme_data) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/atheme/service.rb', line 12 def self.create_service_object(method, service, atheme_data) if parser_for?(service, method) parser = Atheme::Support.constantize("Atheme::Parser::#{service}::#{method.capitalize}") self.new(atheme_data).extend(parser) else self.new(atheme_data) end end |
.inherited(klass) ⇒ Object
8 9 10 |
# File 'lib/atheme/service.rb', line 8 def self.inherited(klass) Atheme::SERVICES << klass.name.gsub('Atheme::', '') end |
.method_missing(method, *args, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/atheme/service.rb', line 22 def self.method_missing(method, *args, &block) raise Atheme::Error::InvalidUser, 'No user has been set' if Atheme.user.nil? service = self.name.gsub('Atheme::', '') self.create_service_object(method, service, Atheme.call('atheme.command', Atheme.user., Atheme.user.username, Atheme.user.ip, service, method, *args)) end |