Class: FlavourSaver::Helpers::Defaults

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

Direct Known Subclasses

Decorator

Instance Method Summary collapse

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(message)
  FS.logger.debug("FlavourSaver: #{message}")
  ''
end

#thisObject



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