Class: Hotdog::Commands::BaseCommand
- Inherits:
-
Object
- Object
- Hotdog::Commands::BaseCommand
- Defined in:
- lib/hotdog/commands.rb
Constant Summary collapse
- PERSISTENT_DB =
"persistent.db"
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #execute(query, *args) ⇒ Object
- #fixed_string? ⇒ Boolean
-
#initialize(application) ⇒ BaseCommand
constructor
A new instance of BaseCommand.
- #run(args = []) ⇒ Object
Constructor Details
#initialize(application) ⇒ BaseCommand
Returns a new instance of BaseCommand.
13 14 15 16 17 18 |
# File 'lib/hotdog/commands.rb', line 13 def initialize(application) @application = application @logger = application.[:logger] = application. @dog = Dogapi::Client.new([:api_key], [:application_key]) end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
19 20 21 |
# File 'lib/hotdog/commands.rb', line 19 def application @application end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
20 21 22 |
# File 'lib/hotdog/commands.rb', line 20 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/hotdog/commands.rb', line 21 def end |
Instance Method Details
#execute(query, *args) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/hotdog/commands.rb', line 27 def execute(query, *args) update_db q = query.strip if 0 < args.length q += " -- VALUES (#{args.map { |arg| Array === arg ? "(#{arg.join(", ")})" : arg.inspect }.join(", ")})" end logger.debug(q) @db.execute(query, args) end |
#fixed_string? ⇒ Boolean
37 38 39 |
# File 'lib/hotdog/commands.rb', line 37 def fixed_string?() [:fixed_string] end |
#run(args = []) ⇒ Object
23 24 25 |
# File 'lib/hotdog/commands.rb', line 23 def run(args=[]) raise(NotImplementedError) end |