Sha256: 9d29b97b8b76e838634bb32b7ed5fbf247d8d21475938a0fa19090deb18c7769

Contents?: true

Size: 803 Bytes

Versions: 3

Compression:

Stored size: 803 Bytes

Contents

require 'singleton'
module BrighterPlanet
  class Metadata
    class Data1Authority
      include ::Singleton
      def authority?(method_id)
        return unless defined?(::Rails) and ::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 == 'Data1'
      rescue ::Exception
        false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brighter_planet_metadata-0.0.16 lib/brighter_planet_metadata/data1_authority.rb
brighter_planet_metadata-0.0.15 lib/brighter_planet_metadata/data1_authority.rb
brighter_planet_metadata-0.0.14 lib/brighter_planet_metadata/data1_authority.rb