Sha256: 61db1578f526411fa3995ee4de1eb1c3b2a9353222dd27eed70d583ce3380e22
Contents?: true
Size: 1.05 KB
Versions: 47
Compression:
Stored size: 1.05 KB
Contents
#encoding: utf-8 class Module # === Support for typing by declaration # Compliance inquirer (declared compliance + ancestors). # def complies?( other_module ) other_module.aT_kind_of Module, "other module" compliance.include? other_module end # Declared complience inquirer. # def declares_compliance?( other_module ) other_module.aT_kind_of Module, "other module" declared_compliance.include? other_module end # Compliance (declared compliance + ancestors). # def compliance ( declared_compliance + ancestors ).uniq end # Declared compliance getter. # def declared_compliance ( ( @declared_compliance || [] ) + ancestors.map { |a| a.instance_variable_get( :@declared_compliance ) || [] }.reduce( [], :+ ) ).uniq end # Declaration of module / class compliance. # def declare_compliance! other_module other_module.aT_kind_of Module, "other module" return false if declared_compliance.include? other_module ( @declared_compliance ||= [] ) << other_module return true end end
Version data entries
47 entries across 47 versions & 1 rubygems