Sha256: 18ceadd2fe0cd1b5a61dd7317a4279de9fa76331bb1177ee0c6adec72f977dac

Contents?: true

Size: 1.65 KB

Versions: 13

Compression:

Stored size: 1.65 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

            # @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
          end
        end
      end
    end
  end
end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ecoportal-api-v2-0.8.26 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.25 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.24 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.23 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.22 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.21 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.20 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.19 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.18 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.17 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.16 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.15 lib/ecoportal/api/v2/page/force/binding.rb
ecoportal-api-v2-0.8.14 lib/ecoportal/api/v2/page/force/binding.rb