class Doorkeepr::Rails::Config

Public Class Methods

new(params={}) click to toggle source
Calls superclass method
# File lib/doorkeepr/rails/config.rb, line 6
def initialize params={}
  params[:url]           = ENV["URL"]
  params[:customer]      = ENV["CUSTOMER"]
  params[:application]   = ENV["APPLICATION"]
  params[:function]      = ENV["SERVICE"]
  super params
  @table = @table.with_indifferent_access
end

Public Instance Methods

set(key, value) click to toggle source
# File lib/doorkeepr/rails/config.rb, line 14
def set key, value
  @table[key] = value
end
to_h() click to toggle source
# File lib/doorkeepr/rails/config.rb, line 17
def to_h
  if defined? ::Rails::Server
    @table[:host]      ||= ::Rails::Server.new.options[:Host].sub(/^0\.0\.0\.0$/,"127.0.0.1") 
    @table[:port]      ||= ::Rails::Server.new.options[:Port]
  end
  @table[:host]        ||= ENV["HOST"]
  @table[:host]        ||= "localhost"
  @table[:port]        ||= ENV["PORT"]
  @table[:port]        ||= 3000
  @table[:url]         ||= ::Rails.application.class.parent_name.underscore.gsub(/_/,"-").sub(/$/,".dev")
  @table[:customer]    ||= ENV["USER"]
  @table[:application] ||= ::Rails.application.class.parent_name.underscore
  @table[:function]    ||= "rails"
  @table[:type]        ||= "http"
  @table[:entrance]    ||= "/doorkeepr/publish"
  @table[:uri]         ||= ("/#{OkComputer.mount_at}") rescue nil
  @table[:uri]         ||= ("/"+Doorkeepr::Rails.mount_at.to_s)
  @table
end
to_json() click to toggle source
# File lib/doorkeepr/rails/config.rb, line 36
def to_json
  to_h.to_json
end