Sha256: a60bbafe4d1474068f4a07898b16aab90d2c7932692f2326cf19d809208933f5

Contents?: true

Size: 567 Bytes

Versions: 6

Compression:

Stored size: 567 Bytes

Contents

module GeoWorks
  module AuthorityService
    extend ActiveSupport::Concern

    included do
      mattr_accessor :authority
    end

    class_methods do
      def select_options
        authority.all.map do |element|
          [element[:label], element[:id]]
        end
      end

      def label(id)
        (authority.find(id) || {}).fetch('term', nil)
      end

      def code(id)
        (authority.find(id) || {}).fetch('code', nil)
      end

      def include?(id)
        !authority.find(id).nil? && !authority.find(id).empty?
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geo_works-0.2.0 app/services/geo_works/authority_service.rb
geo_works-0.1.4 app/services/geo_works/authority_service.rb
geo_works-0.1.3 app/services/geo_works/authority_service.rb
geo_works-0.1.2 app/services/geo_works/authority_service.rb
geo_works-0.1.1 app/services/geo_works/authority_service.rb
geo_works-0.1.0 app/services/geo_works/authority_service.rb