Module: Penetrator::Behavior
- Defined in:
- lib/penetrator.rb
Overview
Concern
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#behaves_like(trait_name, *args, &block) ⇒ Object
ClassMethods.
Class Method Details
.included(base) ⇒ Object
50 51 52 |
# File 'lib/penetrator.rb', line 50 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#behaves_like(trait_name, *args, &block) ⇒ Object
ClassMethods
64 65 66 67 68 69 70 |
# File 'lib/penetrator.rb', line 64 def behaves_like(trait_name, *args, &block) full_name = "#{Penetrator::Inflector.camelize(trait_name.to_s)}Trait" trait = Penetrator::Inflector.constantize(full_name) trait.instance_variable_set(:@_trait_args, args) trait.instance_variable_set(:@_trait_block, block) extend trait end |