Sha256: ea106236758d9bb3af9a6d74f517340d42eefc9b3900e0dbc7e5990c0ff86e0d
Contents?: true
Size: 713 Bytes
Versions: 1
Compression:
Stored size: 713 Bytes
Contents
module NotOnlyButAlso module ClassMethods def not_only_but_also(*contexts, &block) if block_given? self.class_eval(&block) else contexts.each do |context| NotOnlyButAlso::Helpers.require_context_file(name, context) end end end alias also_has not_only_but_also end module Helpers class << self def require_context_file(class_name, context) require_dependency "#{class_name.underscore}/#{context}" rescue MissingSourceFile => e raise e, "NotOnlyButAlso could not find a file for #{class_name} using context #{context}" end end end end ActiveRecord::Base.extend NotOnlyButAlso::ClassMethods
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
not_only_but_also-0.1.0 | lib/not_only_but_also.rb |