module Traitee::Trait
Public Class Methods
subject_composition(*params, &block)
click to toggle source
# File lib/traitee/trait.rb, line 37 def self.subject_composition(*params, &block) Class.new do extend Trait merge(*params) unless params.empty? serves(&block) if block end end
Public Instance Methods
dict()
click to toggle source
# File lib/traitee/trait.rb, line 17 def dict @dict ||= Dict.new end
methods(options = {})
click to toggle source
usable methods
# File lib/traitee/trait.rb, line 22 def methods(options = {}) served_from(this, *this.instance_methods) dict.methods_hash(options) end
Also aliased as: []
served_from(trait_module, *methods)
click to toggle source
store Module where method is defined (trait) and actual method name
# File lib/traitee/trait.rb, line 33 def served_from(trait_module, *methods) methods.each { |method_name| dict << [trait_module, method_name] } end
serves(&method_def)
click to toggle source
helper for actual method definitions
# File lib/traitee/trait.rb, line 28 def serves(&method_def) this.module_eval(&method_def) end
this()
click to toggle source
# File lib/traitee/trait.rb, line 13 def this @this ||= Module.new end