Sha256: 6c3d37ab87df6090853b441410c1891e78c8cc92520f3109ec21d32eb85e0601
Contents?: true
Size: 1.31 KB
Versions: 18
Compression:
Stored size: 1.31 KB
Contents
module Ecoportal module API class V1 class PersonSchema < Common::BaseModel passthrough :id, :name, to: :doc def fields @fields_by_id or index_fields @fields_by_id.values end def fields_by_id @fields_by_id or index_fields @fields_by_id end def fields_by_alt_id @fields_by_alt_id or index_fields @fields_by_alt_id end def [](id) @fields_by_alt_id or index_fields @fields_by_id[id] || @fields_by_alt_id[id] end def index_fields @fields_by_id = {} @fields_by_alt_id = {} doc["fields"].each do |field| wrapped = schema_field_class.new(field) @fields_by_id[wrapped.id] = wrapped @fields_by_alt_id[wrapped.alt_id] = wrapped end end def initialize_details(details) details.schema_id = id details.doc["fields"] = fields.map do |field| field.doc.slice(*%w[id alt_id name multiple type shared]).merge( "value" => field.multiple ? [] : nil ) end end private def schema_field_class V1::SchemaField end end end end end require 'ecoportal/api/v1/schema_field'
Version data entries
18 entries across 18 versions & 1 rubygems