/usr/lib/ruby/1.9.1/requireable.rb is in libvalidatable-ruby1.9.1 1.6.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | module Validatable
module Requireable #:nodoc:
module ClassMethods #:nodoc:
def requires(*args)
required_options.concat args
end
def required_options
@required_options ||= []
end
end
def self.included(klass)
klass.extend ClassMethods
end
def requires(options)
required_options = self.class.required_options.inject([]) do |errors, attribute|
errors << attribute.to_s unless options.has_key?(attribute)
errors
end
raise ArgumentError.new("#{self.class} requires options: #{required_options.join(', ')}") if required_options.any?
true
end
end
end
|