Class: Hotdog::Commands::BaseCommand
- Inherits:
-
Object
- Object
- Hotdog::Commands::BaseCommand
- Defined in:
- lib/hotdog/commands.rb
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #execute(query, *args) ⇒ Object
-
#initialize(db, options = {}) ⇒ BaseCommand
constructor
A new instance of BaseCommand.
- #run(args = []) ⇒ Object
Constructor Details
#initialize(db, options = {}) ⇒ BaseCommand
Returns a new instance of BaseCommand.
9 10 11 12 13 14 15 16 17 |
# File 'lib/hotdog/commands.rb', line 9 def initialize(db, ={}) @db = db @formatter = [:formatter] @logger = [:logger] @tags = [:tags] @application = [:application] @options = @dog = Dogapi::Client.new([:api_key], [:application_key]) end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
18 19 20 |
# File 'lib/hotdog/commands.rb', line 18 def application @application end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
19 20 21 |
# File 'lib/hotdog/commands.rb', line 19 def formatter @formatter 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.
22 23 24 |
# File 'lib/hotdog/commands.rb', line 22 def @options end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
21 22 23 |
# File 'lib/hotdog/commands.rb', line 21 def @tags end |
Instance Method Details
#execute(query, *args) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/hotdog/commands.rb', line 28 def execute(query, *args) 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 |
#run(args = []) ⇒ Object
24 25 26 |
# File 'lib/hotdog/commands.rb', line 24 def run(args=[]) raise(NotImplementedError) end |