Class: Orthorings

Inherits:
Object
  • Object
show all
Defined in:
lib/orthorings.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cacheObject

Returns the value of attribute cache.



24
25
26
# File 'lib/orthorings.rb', line 24

def cache
  @cache
end

.cache_expiryObject

Returns the value of attribute cache_expiry.



24
25
26
# File 'lib/orthorings.rb', line 24

def cache_expiry
  @cache_expiry
end

Class Method Details

.caching(file, expiry = 300, options = {}) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/orthorings.rb', line 42

def caching(file, expiry = 300, options = {})
  klass = file.to_s.split('_').collect { |e| e.capitalize }.join
  Moneta.autoload(klass.to_sym, "moneta/#{file}")
  @cache = Moneta.const_get(klass).new(options)
  @cache_expiry = expiry
  @cache_options = options.merge(:expires_in => @cache_expiry)
end

.category(id, template = nil) ⇒ Object



34
35
36
# File 'lib/orthorings.rb', line 34

def category(id, template = nil)
  render(:categories, id, template)
end

.content(id, template = nil) ⇒ Object



26
27
28
# File 'lib/orthorings.rb', line 26

def content(id, template = nil)
  render(:content_items, id, template)
end

.feed(id) ⇒ Object



38
39
40
# File 'lib/orthorings.rb', line 38

def feed(id)
  render(:feeds, id)
end

.query(id, template = nil) ⇒ Object



30
31
32
# File 'lib/orthorings.rb', line 30

def query(id, template = nil)
  render(:queries, id, template)
end

.setup(&block) ⇒ Object

Raises:

  • (ArgumentError)


50
51
52
53
54
55
56
57
58
# File 'lib/orthorings.rb', line 50

def setup(&block)
  raise ArgumentError unless block_given?
  @cache = false # default

  class_eval &block

  raise "No orthor account id given... Please add one to your Orthorings setup block" if Orthorings..nil?
  ActionView::Base.send(:include, OrthorHelper) if defined?(ActionView::Base) && !ActionView::Base.include?(OrthorHelper)
end