Class: AridCache::Framework

Inherits:
Object
  • Object
show all
Defined in:
lib/arid_cache/framework.rb

Overview

A class with framework/application related methods like discovering which version of Rails we are running under.

Instance Method Summary collapse

Instance Method Details

#active_record?(major = nil) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/arid_cache/framework.rb', line 5

def active_record?(major=nil)
  defined?(::ActiveRecord) && (major.nil? || (major && ::ActiveRecord::VERSION::MAJOR == major))
end

#initObject

Include framework hooks for Rails

This method is called by init.rb, which is run by Rails on startup.

Customize rendering. Include custom headers and don’t render the layout for AJAX. Insert the Rack::Ajax middleware to rewrite and handle requests. Add custom attributes to outgoing links.

Hooks for Rails 3 are installed using Railties.



18
19
20
# File 'lib/arid_cache/framework.rb', line 18

def init
  ::ActiveRecord::Base.send(:include, AridCache::ActiveRecord) if active_record?
end