Class: Ecoportal::API::V2::Registers::Register

Inherits:
Common::Content::DoubleModel show all
Defined in:
lib/ecoportal/api/v2/registers/register.rb

Constant Summary

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

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

Instance Method Details

#[](id) ⇒ Object



16
17
18
# File 'lib/ecoportal/api/v2/registers/register.rb', line 16

def [](id)
  templates_by_id[id]
end

#index_templatesObject



24
25
26
27
28
29
30
# File 'lib/ecoportal/api/v2/registers/register.rb', line 24

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

#templatesObject



20
21
22
# File 'lib/ecoportal/api/v2/registers/register.rb', line 20

def templates
  templates_by_id.values
end

#templates_by_idObject



11
12
13
14
# File 'lib/ecoportal/api/v2/registers/register.rb', line 11

def templates_by_id
  @templates_by_id or index_templates
  @templates_by_id
end