Sha256: 801f76571607a5b0d5074f7a58ec0d59e82c074b86a4aad6da4fc7aeebd77bc5
Contents?: true
Size: 1.44 KB
Versions: 6
Compression:
Stored size: 1.44 KB
Contents
require "ostruct" module Doorkeepr module Rails class Config < OpenStruct 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 def set key, value @table[key] = value end 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 def to_json to_h.to_json end private end end end
Version data entries
6 entries across 6 versions & 1 rubygems