class WipeOut::Validators::Attributes
Public Instance Methods
call()
click to toggle source
# File lib/wipe_out/validators/attributes.rb, line 4 def call return if ignored? if missing_attributes.any? names = missing_attributes.map { |name| ":#{name}" }.join(", ") result.add_error("#{ar_class.name} plan is missing attributes: #{names}") end if non_existing_attributes.any? names = non_existing_attributes.map { |name| ":#{name}" }.join(", ") result.add_error("#{ar_class.name} plan has extra attributes: #{names}") end end
Private Instance Methods
attributes()
click to toggle source
# File lib/wipe_out/validators/attributes.rb, line 34 def attributes plan.attributes.keys end
columns()
click to toggle source
# File lib/wipe_out/validators/attributes.rb, line 30 def columns ar_class.columns.map(&:name).map(&:to_sym) end
foreign_keys()
click to toggle source
# File lib/wipe_out/validators/attributes.rb, line 42 def foreign_keys ar_class.reflect_on_all_associations.find_all do |relation| relation.is_a?(ActiveRecord::Reflection::BelongsToReflection) end.map(&:foreign_key).map(&:to_sym) end
ignored_attributes()
click to toggle source
# File lib/wipe_out/validators/attributes.rb, line 38 def ignored_attributes plan.ignored + config.ignored_attributes end
missing_attributes()
click to toggle source
# File lib/wipe_out/validators/attributes.rb, line 22 def missing_attributes columns - attributes - ignored_attributes - foreign_keys end
non_existing_attributes()
click to toggle source
# File lib/wipe_out/validators/attributes.rb, line 26 def non_existing_attributes attributes - columns end