Module: SimplyLoad

Defined in:
lib/simply_load.rb,
lib/simply_load/version.rb

Constant Summary collapse

VERSION =
"0.0.5"

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



28
29
30
31
# File 'lib/simply_load.rb', line 28

def method_missing(method, *args, &block)
  return simply_load_timed($1.to_i, $2.to_s, *args) if method =~ /^simply_load_every_+(.*\d)+_+(second|seconds|minute|minutes|hour|hours)$/  # Call has_role? with is_role_name?
  super
end

Instance Method Details

#simply_load(url, content_or_options_with_block = nil, options = {}, escape = true, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/simply_load.rb', line 5

def simply_load(url, content_or_options_with_block = nil, options = {}, escape = true, &block)
  options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) and block_given?
  options[:class] = "#{options[:class]} simply_load".strip
  options.merge!(:"data-href" => url)
  if block_given?
     :div, capture(&block), options, escape
  else
     :div, content_or_options_with_block, options, escape
  end
end

#simply_load_timed(t, unit, url, content_or_options_with_block = nil, options = {}, escape = true, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/simply_load.rb', line 16

def simply_load_timed(t, unit, url, content_or_options_with_block = nil, options = {}, escape = true, &block)
  timer = t.send(unit).seconds * 1000
  options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) and block_given?
  options[:class] = "#{options[:class]} simply_load simply_load_timed".strip
  options.merge!(:"data-href" => url, :"data-timer" => timer)
  if block_given?
     :div, capture(&block), options, escape
  else
     :div, content_or_options_with_block, options, escape
  end
end