lib/usable.rb in usable-3.5.0 vs lib/usable.rb in usable-3.6.0

- old
+ new

@@ -9,10 +9,16 @@ # Keep track of extended classes and modules so we can freeze all usables on boot in production environments def self.extended_constants @extended_constants ||= Set.new end + def self.freeze + extended_constants.each { |const| const.usables.freeze } + extended_constants.freeze + super + end + def self.extended(base) if base.is_a? Class # Define an instance level version of +usables+ base.class_eval do def usables @@ -37,10 +43,16 @@ end end extended_constants << base end + def inherited(base) + base.usables += usables + Usable.extended_constants << base + super + end + def usables @usables ||= Config.new end attr_writer :usables @@ -96,5 +108,7 @@ # @return [Method] bound to the given -context- def usable_method(context, method_name) usables.available_methods[method_name].bind(context) end end + +require 'usable/railtie' if defined?(Rails::Railtie)