Sha256: b940ac0003cf516aed733c886f9e8fda61300498d7626d4c7f92f5de61ddec15

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

require 'singleton'
module BrighterPlanet
  class Metadata
    class Data1Authority
      include ::Singleton
      def authority?(method_id)
        return unless ::Rails.env.production? and brighter_planet_server?
        respond_to? method_id
      end
      def resources
        ::Earth.resources.sort
      end
      def datasets
        ::Dir[::File.expand_path(::File.join(::Rails.root, 'app', 'models', '**', '*.rb'))].select { |f| ::File.read(f) =~ /class [\:A-Za-z0-9]+ < Dataset/ }.map { |path| ::File.basename(path, '.rb').camelcase }.sort
      end
      private
      def brighter_planet_server?
        require 'brighter_planet_deploy'
        ::BrighterPlanet.deploy.servers.me.service == 'ReferenceDataService'
      rescue ::Exception
        false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brighter_planet_metadata-0.0.12 lib/brighter_planet_metadata/data1_authority.rb