Sha256: d8640117275584878dd12c1b9b181b0dd2ef577a5178c18d02f27e968db2e081

Contents?: true

Size: 2 KB

Versions: 4

Compression:

Stored size: 2 KB

Contents

module Ecoportal
  module API
    class V2
      class Page
        class Force
          class Binding < Common::Content::DoubleModel
            class << self
              def new_doc
                {
                  "id"      => new_uuid
                }
              end
            end
            COMPONENT_TYPE = "membrane_binding"
            SECTION_TYPE   = "flow_node_binding"

            passkey     :id
            passforced  :patch_ver, default: 1
            passthrough :name, :reference_id, :type

            def ooze
              self._parent.ooze
            end

            def force
              self._parent.force
            end

            # @return [Boolean] whether or not this the binding refers to a Component
            def component?
              type == COMPONENT_TYPE
            end

            # @return [Boolean] whether or not this the binding refers to a Section
            def section?
              type == SECTION_TYPE
            end

            # @return [Ecoportal::API::V2::Page::Component] field referenced by this binding.
            def component
              raise "This is not a component binding, but a section binding" unless component?
              ooze.components.get_by_id(reference_id)
            end

            # @return [Ecoportal::API::V2::Page::Section] section referenced by this binding.
            def section
              raise "This is not a section binding, but a component binding" unless section?
              ooze.sections.get_by_id(reference_id)
            end

            # @return [Ecoportal::API::V2::Page::Component, Ecoportal::API::V2::Page::Section]
            def reference
              self.component? ? component : section
            end

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

require 'ecoportal/api/v2/page/force/binding'
require 'ecoportal/api/v2/page/force/bindings'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-v2-0.9.5 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.9.4 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.9.3 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.9.2 lib/ecoportal/api/v2/page/force/binding.rb