Class: Ecoportal::API::V2::Page::Force

Inherits:
Common::Content::DoubleModel show all
Defined in:
lib/ecoportal/api/v2/page/force.rb,
lib/ecoportal/api/v2/page/force/helper.rb,
lib/ecoportal/api/v2/page/force/binding.rb,
lib/ecoportal/api/v2/page/force/bindings.rb

Defined Under Namespace

Classes: Binding, Bindings, Helper

Constant Summary collapse

INITIAL_WEIGHT =
9999

Constants included from Common::Content::DoubleModel::Diffable

Common::Content::DoubleModel::Diffable::DIFF_CLASS

Constants included from Common::Content::DoubleModel::Base

Common::Content::DoubleModel::Base::NOT_USED

Instance Attribute Summary

Attributes included from Common::Content::DoubleModel::Parented

#_parent, #_parent_key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Common::Content::DoubleModel

#initialize, new_uuid

Methods included from Common::Content::DoubleModel::Diffable

#as_update, #dirty?

Methods included from Common::Content::Includer

#include_missing

Constructor Details

This class inherits a constructor from Ecoportal::API::Common::Content::DoubleModel

Class Method Details

.new_docObject



9
10
11
12
13
14
# File 'lib/ecoportal/api/v2/page/force.rb', line 9

def new_doc
  {
    'id'     => new_uuid,
    'weight' => INITIAL_WEIGHT
  }
end

Instance Method Details

#bind(reference, **kargs, &block) ⇒ Object



34
35
36
# File 'lib/ecoportal/api/v2/page/force.rb', line 34

def bind(reference, **kargs, &block)
  bindings.add(reference, **kargs, &block)
end

#custom_script=(value) ⇒ Object

It updates script by using helpers



39
40
41
42
# File 'lib/ecoportal/api/v2/page/force.rb', line 39

def custom_script=(value)
  doc['custom_script'] = value
  update_script
end

#oozeObject



29
30
31
# File 'lib/ecoportal/api/v2/page/force.rb', line 29

def ooze
  _parent.ooze
end

#update_scriptObject

It sets the script value by using custom_script and helpers[N..1].script



45
46
47
# File 'lib/ecoportal/api/v2/page/force.rb', line 45

def update_script
  doc['script'] = helpers.to_a.reverse.map(&:script).push(custom_script).join("\n")
end