Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Commit

Permalink
リファクタリング: 不要な確認処理を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
YOSHIDA Hiroki committed Jul 3, 2014
1 parent beb4e9e commit f2d3ec1
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 11 deletions.
1 change: 0 additions & 1 deletion app/models/comable/cart_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class CartItem < ActiveRecord::Base
validates Comable::Customer.foreign_key, uniqueness: { scope: [Comable::Customer.foreign_key, Comable::Stock.foreign_key] }

def stock
return comable_stock unless respond_to?(:comable_values)
return comable_stock unless comable_values[:flag]
stock = comable_stock
return if stock.nil?
Expand Down
4 changes: 1 addition & 3 deletions lib/acts_as_comable_customer/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ def reset_cart

def cart_items
return super unless self.logged_in?
comable_flag = false
comable_flag = comable_values[:flag] if respond_to?(:comable_values)
Comable::CartItem.comable(comable_flag).where(Comable::Customer.foreign_key => id)
Comable::CartItem.comable(comable_values[:flag]).where(Comable::Customer.foreign_key => id)
end

def cart
Expand Down
1 change: 0 additions & 1 deletion lib/acts_as_comable_product/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def acts_as_comable_product

module InstanceMethods
def stocks
return comable_stocks unless respond_to?(:comable_values)
return comable_stocks unless comable_values[:flag]
stocks = comable_stocks
return if stocks.nil?
Expand Down
1 change: 0 additions & 1 deletion lib/acts_as_comable_stock/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def acts_as_comable_stock

module InstanceMethods
def product
return comable_product unless respond_to?(:comable_values)
return comable_product unless comable_values[:flag]
product = comable_product
return if product.nil?
Expand Down
2 changes: 0 additions & 2 deletions lib/comable/columns_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def warning_checker
#
module RelationMethod
def relation(*args, &block)
return super unless self.respond_to?(:comable)
return super unless current_scope
return super unless current_scope.comable_values
return super unless current_scope.comable_values[:flag]
Expand All @@ -219,7 +218,6 @@ module Relation
# #=> true (= products.title)
#
def to_a
return super unless @klass.include?(InstanceMethods)
return super unless comable_values[:flag]
super.each { |record| record.comable!(comable_values[:type]) }
end
Expand Down
4 changes: 1 addition & 3 deletions lib/comable/customer_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def add_stock_to_cart(stock)
found_cart_item = found_cart_items.first
found_cart_item.quantity = found_cart_item.quantity.next
else
comable_flag = false
comable_flag = comable_values[:flag] if respond_to?(:comable_values)
@cart_items << Comable::CartItem.comable(comable_flag).new(Comable::Stock.foreign_key => stock.id)
@cart_items << Comable::CartItem.comable(comable_values[:flag]).new(Comable::Stock.foreign_key => stock.id)
end
save_cart_to_session
end
Expand Down

0 comments on commit f2d3ec1

Please sign in to comment.