Sha256: 0fdfa45bacd24d2d6a86ffc3c254fc9a0087942852cfb4c28bb9a951e48a4054
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
module Tins module Concern def self.extended(base) base.instance_variable_set("@_dependencies", []) end def append_features(base) if base.instance_variable_defined?("@_dependencies") base.instance_variable_get("@_dependencies") << self false else return false if base < self @_dependencies.each { |dep| base.send(:include, dep) } super base.extend const_get("ClassMethods") if const_defined?("ClassMethods") base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block") Thread.current[:tin_concern_args] = nil true end end def prepend_features(base) if base.instance_variable_defined?("@_dependencies") base.instance_variable_get("@_dependencies") << self false else return false if base < self @_dependencies.each { |dep| base.send(:include, dep) } super base.extend const_get("ClassMethods") if const_defined?("ClassMethods") base.class_eval(&@_prepended_block) if instance_variable_defined?("@_prepended_block") Thread.current[:tin_concern_args] = nil true end end def included(base = nil, &block) if base.nil? instance_variable_defined?(:@_included_block) and raise StandardError, "included block already defined" @_included_block = block else super end end def prepended(base = nil, &block) if base.nil? instance_variable_defined?(:@_prepended_block) and raise StandardError, "prepended block already defined" @_prepended_block = block else super end end def class_methods(&block) modul = const_get(:ClassMethods) if const_defined?(:ClassMethods, false) unless modul modul = Module.new const_set(:ClassMethods, modul) end modul.module_eval(&block) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tins-1.38.0 | lib/tins/concern.rb |
tins-1.37.1 | lib/tins/concern.rb |
tins-1.37.0 | lib/tins/concern.rb |