Module: Scales::Worker::Cache::XML

Includes:
Helper::ContentTypes
Defined in:
lib/scales-worker/cache/xml.rb

Class Method Summary collapse

Class Method Details

.append(params = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/scales-worker/cache/xml.rb', line 9

def append(params = {})
  xml = params[:xml]
  path = params[:to] || params[:at]
  change_content_at(path, params[:select]) do |selection|
    selection.each{ |element| element.children.last.after xml }
  end
end

.prepend(params = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/scales-worker/cache/xml.rb', line 17

def prepend(params = {})
  xml = params[:xml]
  path = params[:to] || params[:at]
  change_content_at(path, params[:select]) do |selection|
    selection.each{ |element| element.children.first.before xml }
  end
end

.remove(params = {}) ⇒ Object



41
42
43
44
45
46
# File 'lib/scales-worker/cache/xml.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/xml.rb', line 33

def replace(params = {})
  xml = params[:xml]
  path = params[:to] || params[:at]
  change_content_at(path, params[:select]) do |selection|
    selection.each{ |element| element.replace xml }
  end
end

.set(params = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/scales-worker/cache/xml.rb', line 25

def set(params = {})
  xml = params[:xml]
  path = params[:to] || params[:at]
  change_content_at(path, params[:select]) do |selection|
    selection.each{ |element| element.inner_html = xml }
  end
end