Module: Fabrik::Trait
Instance Method Summary collapse
- #dictionary ⇒ Object
- #methods(opts = {}) ⇒ Object (also: #[])
- #own ⇒ Object
- #provides(&own_definition) ⇒ Object
- #provides_from(mod, *names) ⇒ Object
Methods included from Composer
Instance Method Details
#dictionary ⇒ Object
32 33 34 |
# File 'lib/fabrik/trait.rb', line 32 def dictionary @dictionary ||= Dictionary.new end |
#methods(opts = {}) ⇒ Object Also known as: []
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
28 29 30 |
# File 'lib/fabrik/trait.rb', line 28 def own @own ||= Module.new end |
#provides(&own_definition) ⇒ Object
18 19 20 |
# File 'lib/fabrik/trait.rb', line 18 def provides(&own_definition) own.module_eval(&own_definition) end |
#provides_from(mod, *names) ⇒ Object
22 23 24 25 26 |
# File 'lib/fabrik/trait.rb', line 22 def provides_from(mod, *names) names.each do |name| dictionary.add([mod, name]) end end |