module Fabrik::Trait
Public Class Methods
build(*args, &blk)
click to toggle source
# File lib/fabrik/trait.rb, line 12 def self.build(*args, &blk) Class.new do extend Trait compose(*args) if args.count > 0 provides(&blk) if blk end end
Public Instance Methods
dictionary()
click to toggle source
# File lib/fabrik/trait.rb, line 40 def dictionary @dictionary ||= Dictionary.new end
methods(opts = {})
click to toggle source
# File lib/fabrik/trait.rb, line 20 def methods(opts = {}) provides_from(own, *own.instance_methods) dictionary.method_map(opts) end
Also aliased as: []
own()
click to toggle source
# File lib/fabrik/trait.rb, line 36 def own @own ||= Module.new end
provides(&own_definition)
click to toggle source
# File lib/fabrik/trait.rb, line 26 def provides(&own_definition) own.module_eval(&own_definition) end
provides_from(mod, *names)
click to toggle source
# File lib/fabrik/trait.rb, line 30 def provides_from(mod, *names) names.each do |name| dictionary.add([mod, name]) end end