Class: DBA::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/dba/command.rb

Direct Known Subclasses

Diagram, Diff, Dump, Load, Pull, RowCommand, Sample, Select, TableCommand, Tables

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ Command

Returns a new instance of Command.



14
15
16
# File 'lib/dba/command.rb', line 14

def initialize(database)
  self.database = database
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



18
19
20
# File 'lib/dba/command.rb', line 18

def database
  @database
end

#table_nameObject

Returns the value of attribute table_name.



20
21
22
# File 'lib/dba/command.rb', line 20

def table_name
  @table_name
end

Class Method Details

.arity_check(args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/dba/command.rb', line 2

def self.arity_check(args)
  parameters = instance_method(:call).parameters

  required, optional = parameters.partition { |(type, name)| type == :req }

  expected = optional.empty? ? required.size : (required.size .. required.size + optional.size)

  unless expected === args.size
    raise DBA::Error, "incorrect number of arguments (given #{args.size}, expected #{expected})"
  end
end