Sha256: 92473305856d8aeb303949abd88e2b5bbdae3d414aa7b28338e529bb865751e2

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'singleton'
module BrighterPlanet
  class Metadata
    class Cm1Authority
      include ::Singleton
      def authority?(universe, method_id)
        return unless universe == 'cm1_production'
        method_id = method_id.to_s
        if method_id == 'certified_emitters'
          defined?(::Rails) and ::Rails.application.certified?
        else
          respond_to? method_id
        end
      end
      def emitters
        ary = []
        ::ObjectSpace.each_object(::BrighterPlanet::Emitter) do |obj|
          ary.push obj.name.demodulize
        end
        ary
      end
      def certified_emitters
        emitters
      end
      def protocols
        emitters.map(&:constantize).map(&:protocols).flatten.uniq.inject({}) do |memo, p|
          memo[p] = ::File.read(::File.join(::Rails.root, 'app', 'views', 'protocols', 'names', "_#{p}.html.erb")).strip
          memo
        end
      end
      def color
        (AuthoritativeDnsResolver.getaddress('carbon.brighterplanet.com') == '184.73.240.13') ? 'red' : 'blue'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brighter_planet_metadata-0.0.4 lib/brighter_planet_metadata/cm1_authority.rb
brighter_planet_metadata-0.0.3 lib/brighter_planet_metadata/cm1_authority.rb
brighter_planet_metadata-0.0.2 lib/brighter_planet_metadata/cm1_authority.rb