lib/valle/hooks.rb in valle-0.0.2 vs lib/valle/hooks.rb in valle-0.0.3
- old
+ new
@@ -6,11 +6,11 @@
##
# Runs all the hooks, required for this gem
#
def init
ActiveSupport.on_load(:active_record) do
- Valle::Hooks.extend_inherited_method
+ Valle::Hooks.extend_inherited_method if Valle.enabled?
end
end
##
# Extends the functionality of inherited method
@@ -18,11 +18,13 @@
def extend_inherited_method
ActiveRecord::Base.class_eval do
class << self
def inherited_with_valle_validators(subclass)
inherited_without_valle_validators(subclass)
- Valle::Hooks.extend_ar_validations_valid_method(subclass)
+ if Valle.can_process_model?(subclass.model_name)
+ Valle::Hooks.extend_ar_validations_valid_method(subclass)
+ end
end
alias_method_chain :inherited, :valle_validators
end
end
@@ -39,10 +41,10 @@
cattr_accessor :valle_validators
end
subclass.class_eval do
def valid_with_valle_validators?(context = nil)
- self.class.valle_validators ||= Valle::BoundsManager.add_validators(self.class)
+ self.class.valle_validators ||= Valle::Manager.add_validators(self.class)
valid_without_valle_validators?(context)
end
alias_method_chain :valid?, :valle_validators
end