Module: SimplyLoad
- Defined in:
- lib/simply_load.rb,
lib/simply_load/version.rb
Constant Summary collapse
- VERSION =
"0.0.5"
Instance Method Summary collapse
- #method_missing(method, *args, &block) ⇒ Object
- #simply_load(url, content_or_options_with_block = nil, options = {}, escape = true, &block) ⇒ Object
- #simply_load_timed(t, unit, url, content_or_options_with_block = nil, options = {}, escape = true, &block) ⇒ Object
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, = nil, = {}, escape = true, &block) = if .is_a?(Hash) and block_given? [:class] = "#{[:class]} simply_load".strip .merge!(:"data-href" => url) if block_given? content_tag :div, capture(&block), , escape else content_tag :div, , , 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, = nil, = {}, escape = true, &block) timer = t.send(unit).seconds * 1000 = if .is_a?(Hash) and block_given? [:class] = "#{[:class]} simply_load simply_load_timed".strip .merge!(:"data-href" => url, :"data-timer" => timer) if block_given? content_tag :div, capture(&block), , escape else content_tag :div, , , escape end end |