Class: Officer::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/officer/commands.rb

Direct Known Subclasses

Connections, Lock, Locks, MyLocks, Reset, Unlock

Class Method Summary collapse

Instance Method Summary collapse

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

.registerObject



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

#executeObject



35
36
37
# File 'lib/officer/commands.rb', line 35

def execute
  raise 'Must override.'
end