Navigation Menu

Skip to content

Commit

Permalink
Pass validated values to avoid typos in parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 23, 2014
1 parent ed42439 commit 275abcc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
10 changes: 4 additions & 6 deletions lib/droonga/plugins/groonga/column_create.rb
Expand Up @@ -36,15 +36,14 @@ def process_request(request)
end

if @command.column_index?
define_index
define_index(table_name)
else
define_column
define_column(table_name)
end
end

private
def define_column
table_name = @command["table"]
def define_column(table_name)
column_name = @command["name"]
column_type = @command["type"]

Expand Down Expand Up @@ -76,8 +75,7 @@ def create_column_options_flags(options)
options
end

def define_index
table_name = @command["table"]
def define_index(table_name)
target_table = @command["type"]
target_columns = (@command["source"] || "").split(/\s*,\s*/)

Expand Down
7 changes: 2 additions & 5 deletions lib/droonga/plugins/groonga/column_remove.rb
Expand Up @@ -43,14 +43,11 @@ def process_request(request)
:result => false)
end

remove_column
remove_column(table_name, column_name)
end

private
def remove_column
table_name = @command["table"]
column_name = @command["name"]

def remove_column(table_name, column_name)
::Groonga::Schema.define(:context => @context) do |schema|
schema.change_table(table_name) do |table|
table.remove_column(column_name)
Expand Down
10 changes: 4 additions & 6 deletions lib/droonga/plugins/groonga/column_rename.rb
Expand Up @@ -43,15 +43,13 @@ def process_request(request)
:result => false)
end

rename_column
new_name = @command["new_name"]

rename_column(table_name, column_name, new_name)
end

private
def rename_column
table_name = @command["table"]
column_name = @command["name"]
new_name = @command["new_name"]

def rename_column(table_name, column_name, new_name)
::Groonga::Schema.define(:context => @context) do |schema|
schema.change_table(table_name) do |table|
table.rename_column(column_name, new_name)
Expand Down

0 comments on commit 275abcc

Please sign in to comment.