Sha256: 3901d5be110c0a5b0434b8a7736b6cd0af296c0ced1b65a78d9a6198e5e96747

Contents?: true

Size: 879 Bytes

Versions: 6

Compression:

Stored size: 879 Bytes

Contents

module Ecoportal
  module API
    class V2
      class Registers
        class Register < Ecoportal::API::Common::Content::DoubleModel
          passkey     :id
          passthrough :name

          class_resolver :template_class, "Ecoportal::API::V2::Registers::Template"

          def templates_by_id
            @templates_by_id or index_templates
            @templates_by_id
          end

          def [](id)
            templates_by_id[id]
          end

          def templates
            templates_by_id.values
          end

          def index_templates
            @templates_by_id   = {}
            doc["templates"].each do |template_doc|
              template = template_class.new(template_doc)
              @templates_by_id[template.id] = template
            end
          end

        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ecoportal-api-v2-2.0.12 lib/ecoportal/api/v2/registers/register.rb
ecoportal-api-v2-2.0.11 lib/ecoportal/api/v2/registers/register.rb
ecoportal-api-v2-2.0.10 lib/ecoportal/api/v2/registers/register.rb
ecoportal-api-v2-2.0.9 lib/ecoportal/api/v2/registers/register.rb
ecoportal-api-v2-2.0.8 lib/ecoportal/api/v2/registers/register.rb
ecoportal-api-v2-2.0.7 lib/ecoportal/api/v2/registers/register.rb