Skip to content

Commit

Permalink
Merge pull request #116 from rakuten-ws/refactoring
Browse files Browse the repository at this point in the history
Refactoring: fix some style issues
  • Loading branch information
satoryu authored Nov 3, 2019
2 parents 21f9eb0 + 17a305f commit 03189cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion lib/rakuten_web_service/recipe/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def ranking

def parent_category
return nil if parent_category_type.nil?
Recipe.categories(parent_category_type).find { |c| c.id.to_i == parent_category_id.to_i }
Recipe.categories(parent_category_type).find do |c|
c.id.to_i == parent_category_id.to_i
end
end

def absolute_category_id
Expand Down
21 changes: 10 additions & 11 deletions lib/rakuten_web_service/search_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,19 @@ def params_to_get_next_page

def order(options)
new_params = params.dup
if options.is_a? Hash
key, sort_order = *options.to_a.last
key = key.to_s.to_camel
new_params[:sort] = case sort_order.to_s.downcase
when 'desc'
"-#{key}"
when 'asc'
"+#{key}"
end
elsif options.to_s == 'standard'
if options.to_s == 'standard'
new_params[:sort] = 'standard'
else
return self.class.new(new_params, @resource_class)
end
unless options.is_a? Hash
raise ArgumentError, "Invalid Sort Option: #{options.inspect}"
end

key, sort_order = *options.to_a.last
case sort_order.to_s.downcase
when 'desc' then new_params[:sort] = "-#{key}".to_camel
when 'asc' then new_params[:sort] = "+#{key}".to_camel
end
self.class.new(new_params, @resource_class)
end

Expand Down
6 changes: 3 additions & 3 deletions lib/rakuten_web_service/travel/area_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def search(options = {})
end

def [](class_code)
LargeClass[class_code] or
MiddleClass[class_code] or
SmallClass[class_code] or
LargeClass[class_code] ||
MiddleClass[class_code] ||
SmallClass[class_code] ||
DetailClass[class_code]
end
module_function :search, :[]
Expand Down

0 comments on commit 03189cd

Please sign in to comment.