module Superseeder::Adapters::ActiveRecord
Public Instance Methods
each_field(row) { |field, false, false end| ... }
click to toggle source
# File lib/superseeder/adapters/active_record.rb, line 11 def each_field(row) self.instance.attributes.each do |field, val| next unless row.key? field yield field, false, false #self.is_array_field?(options) TODO inquiry end end protected def is_array_field?(options) options.type == Array end def is_hash_field?(options) options.type == Hash end def is_array_relation?(reflection) [::ActiveRecord::Reflection::HasManyReflection, ::ActiveRecord::Reflection::HasAndBelongsToManyReflection].any?{ |c| reflection.kind_of? c } end end
each_relation() { |key, is_array_relation?(val), class_name.constantize| ... }
click to toggle source
# File lib/superseeder/adapters/active_record.rb, line 5 def each_relation self.instance.singleton_class.reflections.each do |key, val| yield key, self.is_array_relation?(val), val.class_name.constantize end end
is_array_field?(options)
click to toggle source
# File lib/superseeder/adapters/active_record.rb, line 20 def is_array_field?(options) options.type == Array end
is_array_relation?(reflection)
click to toggle source
# File lib/superseeder/adapters/active_record.rb, line 28 def is_array_relation?(reflection) [::ActiveRecord::Reflection::HasManyReflection, ::ActiveRecord::Reflection::HasAndBelongsToManyReflection].any?{ |c| reflection.kind_of? c } end
is_hash_field?(options)
click to toggle source
# File lib/superseeder/adapters/active_record.rb, line 24 def is_hash_field?(options) options.type == Hash end