Sha256: f690a040e552de3d3876b3f00ee1dffc086b13db3fbfc2bd718a479b5654628a

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require 'active_support'
require 'active_support/inflector'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/class/inheritable_attributes'
require 'old_api_resource/core_extensions'
require 'active_model'
require 'log4r'
require 'log4r/outputter/consoleoutputters'

require 'old_api_resource/exceptions'

module OldApiResource
  
  extend ActiveSupport::Autoload
  
  autoload :Associations
  autoload :Attributes
  autoload :Base
  autoload :Callbacks
  autoload :Connection
  autoload :CustomMethods
  autoload :Formats
  autoload :Observing
  autoload :Mocks
  autoload :ModelErrors
  autoload :Validations
  autoload :LogSubscriber
  
  mattr_writer :logger
  mattr_accessor :raise_missing_definition_error; self.raise_missing_definition_error = false
  
  # Load a fix for inflections for words ending in ess
  ActiveSupport::Inflector.inflections do |inflect|
    inflect.singular(/ess$/i, 'ess')
  end
  
  def self.load_mocks_and_factories
    require 'hash_dealer'
    Mocks.clear_endpoints
    Mocks.init
    
    Dir["#{File.dirname(__FILE__)}/../spec/support/requests/*.rb"].each {|f| require f}
    Dir["#{File.dirname(__FILE__)}/../spec/support/**/*.rb"].each {|f| require f}
  end
  
  def self.site=(new_site)
    OldApiResource::Base.site = new_site
  end
  
  def self.format=(new_format)
    OldApiResource::Base.format = new_format
  end
  # logger
  def self.logger
    return @logger if @logger
    @logger = Log4r::Logger.new("old_api_resource")
    @logger.outputters = [Log4r::StdoutOutputter.new('console')]
    @logger.level = Log4r::INFO
    @logger
  end
  
  # Use this method to enable logging in the future
  # def self.logging(val = nil)
  #   return (@@logging || false) unless val
  #   return @@logging = val
  # end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
old_api_resource-0.3.0 lib/old_api_resource.rb