Sha256: 684ad57424d291dcd66e365225a418e8c4712e1276266863f0cae37b7c46c994

Contents?: true

Size: 916 Bytes

Versions: 1

Compression:

Stored size: 916 Bytes

Contents

require 'opennorth/represent/models/offices'

module Opennorth
  class Represent
    class Representative < Fog::Model

      attribute :name,           type: :string
      attribute :district_name,  type: :string
      attribute :elected_office, type: :string
      attribute :source_url,     type: :string

      attribute :offices,        type: :array

      attribute :extra

      def validate!
        requires :name, :district_name, :elected_office, :source_url
      end

      def offices
        attributes.fetch(:offices) { attributes[:offices] = Opennorth::Represent::Offices.new(service: service).load([]) }
      end

      def offices=(new_offices)
        self.offices.clear
        self.offices.load(new_offices)
      end

      def honorific_prefix
        self.extra["honorific_prefix"]
      end

      def preferred_language
        self.extra["preferred_language"]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opennorth-represent-0.1.0 lib/opennorth/represent/models/representative.rb