Navigation Menu

Skip to content

Commit

Permalink
Extract common code that gets record value
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 19, 2013
1 parent 4278da5 commit 38a27e7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/droonga/plugin/handler_search.rb
Expand Up @@ -262,17 +262,21 @@ def format_records(formatted_result)
def complex_record(attributes, record)
values = {}
attributes.collect do |attribute|
values[attribute[:label]] = attribute[:static_value] || record[attribute[:source]]
values[attribute[:label]] = record_value(record, attribute)
end
values
end

def simple_record(attributes, record)
attributes.collect do |attribute|
attribute[:static_value] || record[attribute[:source]]
record_value(record, attribute)
end
end

def record_value(record, attribute)
attribute[:static_value] || record[attribute[:source]]
end

STATIC_INTEGER_VALUE_PATTERN = /\A[-+]?\d+\z/.freeze
STATIC_FLOAT_VALUE_PATTERN = /\A[-+]?\d*\.\d+\z/.freeze
STATIC_STRING_VALUE_PATTERN = /\A("[^"]*"|'[^']*')\z/.freeze
Expand Down

0 comments on commit 38a27e7

Please sign in to comment.