Module: DataMapper::Model::Is
- Included in:
- DataMapper::Model
- Defined in:
- lib/dm-core/model/is.rb
Overview
Module that provides a common way for plugin authors to implement “is … ” traits (object behaviors that can be shared)
Instance Method Summary collapse
-
#is(plugin, *args, &block) ⇒ Object
A common interface to activate plugins for a resource.
Instance Method Details
#is(plugin, *args, &block) ⇒ Object
A common interface to activate plugins for a resource. For instance:
class Widget
include DataMapper::Resource
is :list
end
adds list item behavior to the model. Plugin that wants to conform to “is API” of DataMapper must supply is_+behavior name+ method, for example above it would be is_list.
19 20 21 22 23 24 25 26 27 |
# File 'lib/dm-core/model/is.rb', line 19 def is(plugin, *args, &block) generator_method = "is_#{plugin}".to_sym if respond_to?(generator_method) send(generator_method, *args, &block) else raise PluginNotFoundError, "could not find plugin named #{plugin}" end end |