Class: FlavourSaver::Helpers::Defaults
- Inherits:
-
Object
- Object
- FlavourSaver::Helpers::Defaults
- Defined in:
- lib/flavour_saver/helpers.rb
Direct Known Subclasses
Instance Method Summary collapse
- #each(collection) ⇒ Object
- #if(truthy) ⇒ Object
- #log(message) ⇒ Object
- #this ⇒ Object
- #unless(falsy, &b) ⇒ Object
- #with(args) ⇒ Object
Instance Method Details
#each(collection) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/flavour_saver/helpers.rb', line 10 def each(collection) r = [] count = 0 collection.each do |element| r << yield.contents(element, 'index' => count) count += 1 end yield.rendered! r.join '' end |
#if(truthy) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/flavour_saver/helpers.rb', line 21 def if(truthy) truthy = false if truthy.respond_to?(:size) && (truthy.size == 0) if truthy yield.contents else yield.inverse end end |
#log(message) ⇒ Object
38 39 40 41 |
# File 'lib/flavour_saver/helpers.rb', line 38 def log() FS.logger.debug("FlavourSaver: #{}") '' end |
#this ⇒ Object
34 35 36 |
# File 'lib/flavour_saver/helpers.rb', line 34 def this @source || self end |
#unless(falsy, &b) ⇒ Object
30 31 32 |
# File 'lib/flavour_saver/helpers.rb', line 30 def unless(falsy,&b) self.if(!falsy,&b) end |
#with(args) ⇒ Object
6 7 8 |
# File 'lib/flavour_saver/helpers.rb', line 6 def with(args) yield.contents args end |