Class: Orthorings
- Inherits:
-
Object
- Object
- Orthorings
- Defined in:
- lib/orthorings.rb
Class Attribute Summary collapse
-
.cache ⇒ Object
Returns the value of attribute cache.
-
.cache_expiry ⇒ Object
Returns the value of attribute cache_expiry.
Class Method Summary collapse
- .caching(file, expiry = 300, options = {}) ⇒ Object
- .category(id, template = nil) ⇒ Object
- .content(id, template = nil) ⇒ Object
- .feed(id) ⇒ Object
- .query(id, template = nil) ⇒ Object
- .setup(&block) ⇒ Object
Class Attribute Details
.cache ⇒ Object
Returns the value of attribute cache.
24 25 26 |
# File 'lib/orthorings.rb', line 24 def cache @cache end |
.cache_expiry ⇒ Object
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, = {}) klass = file.to_s.split('_').collect { |e| e.capitalize }.join Moneta.autoload(klass.to_sym, "moneta/#{file}") @cache = Moneta.const_get(klass).new() @cache_expiry = expiry @cache_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
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.account_id.nil? ActionView::Base.send(:include, OrthorHelper) if defined?(ActionView::Base) && !ActionView::Base.include?(OrthorHelper) end |