Sha256: 254ce02bfec9ef35610a9db618c0c73cf0df5627536ae7eb8882953a0216e811

Contents?: true

Size: 909 Bytes

Versions: 4

Compression:

Stored size: 909 Bytes

Contents

require "rails/engine"
require "rails_imager/engine"
require "string-cases"
require "datet"
require "knjrbfw"
require "RMagick" unless ::Kernel.const_defined?(:RMagick)

module RailsImager
  def self.const_missing(name)
    if name.to_s.end_with?("Controller")
      path = "#{File.dirname(__FILE__)}/../app/controllers/rails_imager/#{::StringCases.camel_to_snake(name)}.rb"
    elsif name.to_s.end_with?("Helper")
      path = "#{File.dirname(__FILE__)}/../app/helpers/rails_imager/#{::StringCases.camel_to_snake(name)}.rb"
    else
      path = "#{File.dirname(__FILE__)}/rails_imager/#{::StringCases.camel_to_snake(name)}.rb"
    end

    if File.exists?(path)
      require path
      return const_get(name) if const_defined?(name)
    end

    super
  end

  def self.config
    @config ||= RailsImager::Config.new

    if block_given?
      yield @config
    else
      return @config
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_imager-0.0.25 lib/rails_imager.rb
rails_imager-0.0.24 lib/rails_imager.rb
rails_imager-0.0.23 lib/rails_imager.rb
rails_imager-0.0.22 lib/rails_imager.rb