Class: Copyable::OptionChecker
- Inherits:
-
Object
- Object
- Copyable::OptionChecker
- Defined in:
- lib/copyable/option_checker.rb
Constant Summary collapse
- VALID_OPTIONS =
[:override, :global_override, :skip_validations, :skip_associations]
- VALID_PRIVATE_OPTIONS =
for copyable’s internal use only
[:__called_recursively]
Class Method Summary collapse
Class Method Details
.check!(options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/copyable/option_checker.rb', line 7 def self.check!() = .keys - VALID_OPTIONS - VALID_PRIVATE_OPTIONS if .any? = "Unrecognized options passed to create_copy!:\n" .each do |opt| << " #{opt.inspect}\n" end << "The options passed to create_copy! can only be one of the following:\n" VALID_OPTIONS.each do |opt| << " #{opt.inspect}\n" end raise CopyableError.new() end # :skip_associations needs to be an array if it's present if ([:skip_associations].present? && ![:skip_associations].is_a?(Array)) raise CopyableError.new("When :skip_associations is used, it must be an array") end end |