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 inherited from Common::Content::DoubleModel

Common::Content::DoubleModel::NOT_USED

Constants included from Common::Content::ClassHelpers

Common::Content::ClassHelpers::NOT_USED

Instance Attribute Summary

Attributes inherited from Common::Content::DoubleModel

#_key, #_parent, #_read_only

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Common::Content::DoubleModel

#_doc_key, #as_json, #as_update, #consolidate!, #dirty?, #doc, embeds_many, embeds_one, enforce!, #initialize, #key, #key=, key?, new_uuid, #original_doc, pass_reader, pass_writer, passarray, passboolean, passdate, passforced, passkey, passthrough, #print_pretty, read_only!, read_only?, #read_only?, #replace_doc, #reset!, #resolved_doc_key, #root, #to_json

Methods included from Common::Content::ClassHelpers

#inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant, #to_time, #uid, #used_param?

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