Sha256: 73a00d296f1b8a255a2e48268384e74c034454181c0d2a9599424731c9d7b177

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Meibo
  class Organization
    TYPES = {
      department: 'department',
      school: 'school',
      district: 'district',
      local: 'local',
      state: 'state',
      national: 'national'
    }.freeze

    DataModel.define(
      self,
      attribute_name_to_header_field_map: {
        sourced_id: 'sourcedId',
        status: 'status',
        date_last_modified: 'dateLastModified',
        name: 'name',
        type: 'type',
        identifier: 'identifier',
        parent_sourced_id: 'parentSourcedId'
      },
      converters: {
        datetime: [:date_last_modified],
        enum: { type: [*TYPES.values, ENUM_EXT_PATTERN].freeze },
        required: [:sourced_id, :name, :type],
        status: [:status]
      }
    )

    def initialize(sourced_id:, status: nil, date_last_modified: nil, name:, type:, identifier: nil, parent_sourced_id: (type == TYPES[:district] ? 'NULL' : nil), **extension_fields)
      @sourced_id = sourced_id
      @status = status
      @date_last_modified = date_last_modified
      @name = name
      @type = type
      @identifier = identifier
      @parent_sourced_id = parent_sourced_id
      @extension_fields = extension_fields
    end

    def department?
      type == TYPES[:department]
    end

    def school?
      type == TYPES[:school]
    end

    def district?
      type == TYPES[:district]
    end

    def local?
      type == TYPES[:local]
    end

    def state?
      type == TYPES[:state]
    end

    def national?
      type == TYPES[:national]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
meibo-0.12.0 lib/meibo/organization.rb
meibo-0.11.0 lib/meibo/organization.rb
meibo-0.10.0 lib/meibo/organization.rb
meibo-0.9.0 lib/meibo/organization.rb
meibo-0.8.0 lib/meibo/organization.rb
meibo-0.7.0 lib/meibo/organization.rb
meibo-0.6.0 lib/meibo/organization.rb
meibo-0.5.0 lib/meibo/organization.rb