Module: Catche::Model::ClassMethods

Defined in:
lib/catche/model.rb

Instance Method Summary collapse

Instance Method Details

#catche(options = {}) ⇒ Object

Configures catche

catche :through => :project, :catche_class => Task


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/catche/model.rb', line 25

def catche(options={})
  options = {
    :class          => self,
    :tag_identifier => :id,
    :collection_tag => nil,
    :associations   => [options[:through]].flatten.compact
  }.merge(options)

  options.each do |key, value|
    self.send("catche_#{key}=", value) if self.respond_to?("catche_#{key}")
  end

  self.catche_collection_tag ||= self.catche_class.name.downcase.pluralize
end

#catche_reset!Object



40
41
42
# File 'lib/catche/model.rb', line 40

def catche_reset!
  catche {}
end

#catche_tagObject



44
45
46
# File 'lib/catche/model.rb', line 44

def catche_tag
  self.catche_collection_tag || self.name.downcase.pluralize
end

#catche_tag=(value) ⇒ Object



48
49
50
# File 'lib/catche/model.rb', line 48

def catche_tag=(value)
  self.catche_collection_tag = value
end

#catche_tag_identifierObject



52
53
54
# File 'lib/catche/model.rb', line 52

def catche_tag_identifier
  super || :id
end