Module: DataMapper::Is::Tagger

Included in:
Resource::ClassMethods
Defined in:
lib/dm-is-taggable/is/tagger.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

fired when your plugin gets included into Resource



7
8
9
# File 'lib/dm-is-taggable/is/tagger.rb', line 7

def self.included(base)

end

Instance Method Details

#is_tagger(options = {}) ⇒ Object

Methods that should be included in DataMapper::Model. Normally this should just be your generator, so that the namespace does not get cluttered. ClassMethods and InstanceMethods gets added in the specific resources when you fire is :example



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dm-is-taggable/is/tagger.rb', line 18

def is_tagger(options={})
  unless self.respond_to?(:tagger?)
    # Add class-methods
    extend  DataMapper::Is::Tagger::ClassMethods
    
    # Add instance-methods
    include DataMapper::Is::Tagger::InstanceMethods
  
    cattr_accessor(:taggable_object_classes)
    self.taggable_object_classes = []
  end
  
  raise "options[:for] is missing" unless options[:for]
  
  add_taggable_object_classes(options[:for])
end