Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanl committed Jun 24, 2013
1 parent 9987ee2 commit 41dded2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/searchlight/search.rb
Expand Up @@ -21,10 +21,10 @@ def results
end

def options
search_methods.reduce({}) { |hash, method_name|
option_name = method_name.sub(/\Asearch_/, '')
hash.tap { |hash| hash[option_name.to_sym] = send(option_name) }
}.reject { |option_name, value| is_blank?(value) }
search_attributes.reduce({}) { |hash, option_name|
option_val = send(option_name)
hash.tap { |hash| hash[option_name.to_sym] = option_val unless is_blank?(option_val) }
}
end

protected
Expand All @@ -33,8 +33,8 @@ def options

private

def search_methods
public_methods.map(&:to_s).select { |m| m.start_with?('search_') }
def search_attributes
public_methods.map(&:to_s).select { |m| m.start_with?('search_') }.map { |m| m.sub(/\Asearch_/, '') }
end

def self.guess_search_class!
Expand Down

0 comments on commit 41dded2

Please sign in to comment.