Sha256: 1c249bddc46c1bc890ecc9c13164ffc6d5ff72925e3035ce3b49c129b9cf294e

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

module Orias
  # Dedicated to Orias registrations objects handling
  #
  class Registration < Base
    attr_accessor :raw, :category_name, :status, :subscribed,
      :registration_date, :collect_funds, :mandators

    # Initialize an Orias::Registration instance
    def initialize(attributes = {})
      @raw = attributes

      @category_name = @raw.dig('categoryName')
      @status = @raw.dig('status')
      @subscribed = @status == 'INSCRIT'
      @registration_date = @raw.dig('registrationDate')
      @deletion_date = @raw.dig('deletionDate')
      @collect_funds = @raw.dig('collectFunds') == 'true'

      raw_mandators = @raw.dig('mandators', 'mandator')
      unless raw_mandators.is_a?(Array)
        raw_mandators = [raw_mandators]
      end

      @mandators = raw_mandators.compact.map do |h|
        Orias::Mandator.new(h)
      end
    end

    private

    class << self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
orias-0.4 lib/orias/registration.rb