Module: Fabrik::Trait
Instance Method Summary collapse
- #dictionary ⇒ Object
- #methods(opts = {}) ⇒ Object
- #own ⇒ Object
- #provides(&own_definition) ⇒ Object
- #provides_from(mod, *names) ⇒ Object
Methods included from Composer
Instance Method Details
#dictionary ⇒ Object
31 32 33 |
# File 'lib/fabrik/trait.rb', line 31 def dictionary @dictionary ||= Dictionary.new end |
#methods(opts = {}) ⇒ Object
12 13 14 15 |
# File 'lib/fabrik/trait.rb', line 12 def methods(opts = {}) provides_from(own, *own.instance_methods) dictionary.method_map(opts) end |
#own ⇒ Object
27 28 29 |
# File 'lib/fabrik/trait.rb', line 27 def own @own ||= Module.new end |
#provides(&own_definition) ⇒ Object
17 18 19 |
# File 'lib/fabrik/trait.rb', line 17 def provides(&own_definition) own.module_eval(&own_definition) end |
#provides_from(mod, *names) ⇒ Object
21 22 23 24 25 |
# File 'lib/fabrik/trait.rb', line 21 def provides_from(mod, *names) names.each do |name| dictionary.add([mod, name]) end end |