Class: Officer::Command::Base
- Inherits:
-
Object
- Object
- Officer::Command::Base
- Defined in:
- lib/officer/commands.rb
Class Method Summary collapse
- .register ⇒ Object
-
.underscore(camel_cased_word) ⇒ Object
Originally from ActiveSupport.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(connection, request) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(connection, request) ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 31 32 33 |
# File 'lib/officer/commands.rb', line 26 def initialize connection, request @connection = connection @request = request setup raise('Invalid request') unless valid? end |
Class Method Details
.register ⇒ Object
21 22 23 |
# File 'lib/officer/commands.rb', line 21 def register Factory.register underscore(to_s.split('::').last), self end |
.underscore(camel_cased_word) ⇒ Object
Originally from ActiveSupport
42 43 44 45 46 47 48 |
# File 'lib/officer/commands.rb', line 42 def underscore camel_cased_word camel_cased_word.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |
Instance Method Details
#execute ⇒ Object
35 36 37 |
# File 'lib/officer/commands.rb', line 35 def execute raise 'Must override.' end |