Sha256: d8ff91bf17e19797d31355c3aad0a347f0413d1f959b7d292cb8b62a3238e729

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require "rails/engine"
require "rails_imager/engine"
require "string-cases"
require "datet"
require "knjrbfw"

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

  def self.require_rmagick
    return if ::Kernel.const_defined?(:RMagick)

    begin
      require "rmagick"
    rescue LoadError
      require "RMagick"
    end
  end
end

RailsImager.require_rmagick

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_imager-0.0.29 lib/rails_imager.rb
rails_imager-0.0.28 lib/rails_imager.rb
rails_imager-0.0.27 lib/rails_imager.rb