module ErpBaseErpSvcs::Extensions::ActiveRecord::ActsAsErpType::BelongsToSingletonMethods
Public Instance Methods
fabet( domain_value, options = {} )
click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 135 def fabet( domain_value, options = {} ) find_all_by_erp_type( domain_value, options ) end
fbet( domain_value, options = {})
click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 98 def fbet( domain_value, options = {}) find_by_erp_type( domain_value, options ) end
find_all_by_erp_type( domain_value, options = {} )
click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 139 def find_all_by_erp_type( domain_value, options = {} ) erp_type = options[:class] || @model_id fk_str = options[:foreign_key] || erp_type.to_s + '_id' type_klass = Kernel.const_get( erp_type.to_s.camelcase ) in_clause_array = type_klass.send( domain_value.to_sym ).full_set #puts "id for in clause..." #id_str = erp_type.to_s + '_id' where(fk_str + ' in (?)', in_clause_array) end
find_by_erp_type(domain_value, options = {})
click to toggle source
# File lib/erp_base_erp_svcs/extensions/active_record/acts_as_erp_type.rb, line 102 def find_by_erp_type(domain_value, options = {}) # puts "options...." # puts options[:class] # puts options[:foreign_key] erp_type = options[:class] || @model_id fk_str = options[:foreign_key] || erp_type.to_s + '_id' #*************************************************************** # uncomment these lines for a variety of debugging information #*************************************************************** # klass = self.to_s.underscore + '_type' # puts "default class name" # puts klass # puts "model id" # puts @model_id # # puts "finding by erp type" # puts "self is: #{self}" # puts "type is: #{erp_type}" # puts "fk_str for in clause..." # puts fk_str type_klass = Kernel.const_get( erp_type.to_s.camelcase ) in_clause_array = type_klass.send( domain_value.to_sym ) where(fk_str + ' in (?)', in_clause_array) end