Module: Scales::Worker::Cache::HTML
- Includes:
- Helper::ContentTypes
- Defined in:
- lib/scales-worker/cache/html.rb
Class Method Summary collapse
- .append(params = {}) ⇒ Object
- .prepend(params = {}) ⇒ Object
- .remove(params = {}) ⇒ Object
- .replace(params = {}) ⇒ Object
- .set(params = {}) ⇒ Object
Class Method Details
.append(params = {}) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/scales-worker/cache/html.rb', line 9 def append(params = {}) html = params[:html] path = params[:to] || params[:at] change_content_at(path, params[:select]) do |selection| selection.each{ |element| element.children.last.after html } end end |
.prepend(params = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/scales-worker/cache/html.rb', line 17 def prepend(params = {}) html = params[:html] path = params[:to] || params[:at] change_content_at(path, params[:select]) do |selection| selection.each{ |element| element.children.first.before html } end end |
.remove(params = {}) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/scales-worker/cache/html.rb', line 41 def remove(params = {}) path = params[:to] || params[:at] change_content_at(path, params[:select]) do |selection| selection.each{ |element| element.remove } end end |
.replace(params = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/scales-worker/cache/html.rb', line 33 def replace(params = {}) html = params[:html] path = params[:to] || params[:at] change_content_at(path, params[:select]) do |selection| selection.each{ |element| element.replace html } end end |
.set(params = {}) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/scales-worker/cache/html.rb', line 25 def set(params = {}) html = params[:html] path = params[:to] || params[:at] change_content_at(path, params[:select]) do |selection| selection.each{ |element| element.inner_html = html } end end |