Skip to content

Commit

Permalink
Remove feature to pass options for associations
Browse files Browse the repository at this point in the history
  • Loading branch information
YOSHIDA Hiroki committed Jul 16, 2014
1 parent 227b984 commit 9ea400e
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions lib/utusemi/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,10 @@ def utusemi_association(association_type, name, *args)
scope = args.shift
check_deplicated_association_warning(association_type, name, scope)
utusemi_flag = scope.try(:delete, :utusemi)
scope = utusemi_association_scope(association_type, name, scope) if utusemi_flag
yield name, scope, *args if !utusemi_flag || !method_defined?(name)
define_utusemi_association_reader(name, utusemi_flag => true)
end

def utusemi_association_scope(method_name, name, scope)
utusemi_map = Utusemi.config.map(name.to_s.singularize)
default_scope = { class_name: utusemi_map.class_name }
default_scope[:foreign_key] = utusemi_map.foreign_key if method_name == :belongs_to
default_scope.merge(scope)
end

def define_utusemi_association_reader(name, options = {})
return if method_defined?("#{name}_with_utusemi")
define_method "#{name}_with_utusemi" do |*args|
Expand Down

0 comments on commit 9ea400e

Please sign in to comment.