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

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

Constant Summary collapse

COMPONENT_TYPE =
"membrane_binding"
SECTION_TYPE =
"flow_node_binding"

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



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

def new_doc
  {
    "id"      => new_uuid
  }
end

Instance Method Details

#componentEcoportal::API::V2::Page::Component

Returns field referenced by this binding.

Returns:



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

def component
  raise "This is not a component binding, but a section binding" unless component?
  ooze.components.get_by_id(reference_id)
end

#component?Boolean

Returns whether or not this the binding refers to a Component.

Returns:

  • (Boolean)

    whether or not this the binding refers to a Component



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

def component?
  type == COMPONENT_TYPE
end

#delete!Object



62
63
64
# File 'lib/ecoportal/api/v2/page/force/binding.rb', line 62

def delete!
  self._parent.delete!(self)
end

#forceObject



25
26
27
# File 'lib/ecoportal/api/v2/page/force/binding.rb', line 25

def force
  self._parent.force
end

#oozeObject



21
22
23
# File 'lib/ecoportal/api/v2/page/force/binding.rb', line 21

def ooze
  self._parent.ooze
end

#referenceEcoportal::API::V2::Page::Component, Ecoportal::API::V2::Page::Section



52
53
54
# File 'lib/ecoportal/api/v2/page/force/binding.rb', line 52

def reference
  self.component? ? component : section
end

#replace(mem_sec) ⇒ Object



56
57
58
59
60
# File 'lib/ecoportal/api/v2/page/force/binding.rb', line 56

def replace(mem_sec)
  self._parent.add(mem_sec, name: self.name, before: self) do |bind|
    self.delete! if bind
  end
end

#sectionEcoportal::API::V2::Page::Section

Returns section referenced by this binding.

Returns:



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

def section
  raise "This is not a section binding, but a component binding" unless section?
  ooze.sections.get_by_id(reference_id)
end

#section?Boolean

Returns whether or not this the binding refers to a Section.

Returns:

  • (Boolean)

    whether or not this the binding refers to a Section



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

def section?
  type == SECTION_TYPE
end