Sha256: 951a78fe1caf8cbe8a4065c2f9315affe58b5c496047351fe0b7abe9d6bbec33

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'morale/storage'
require 'morale/platform'

module Morale
  module ConnectionStore
    include Morale::Storage
    include Morale::Platform
    
    def base_url
      # if @base_url.nil?
      #   @base_url = read_connection
      #   if @base_url.nil?
      #     @base_url = default_base_url
      #     self.write_connection
      #   end
      # end
      # @base_url
      'teammorale.com'
    end
    
    def base_url=(value)
      @base_url = value
      self.write_connection
    end
    
    def location
      ENV['CONNECTION_LOCATION'] || default_location
    end
    
    def location=(value)
      ENV['CONNECTION_LOCATION'] = value
    end
    
    def default_location
      "#{home_directory}/.morale/connection"
    end
    
    def delete_connection
      self.delete
      @base_url = nil
    end
    
    def read_connection
      connection = self.read
      connection.split("\n")[0] if connection
    end
    
    def write_connection
      self.write self.base_url
    end
    
    private
    
    def default_base_url
      ENV['DEFAULT_BASE_URL'] || "teammorale.com"
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
morale-client-1.0.2 lib/morale/connection_store.rb