module RailsAgnosticModels::RailsHelpers::ClassMethods

Public Instance Methods

rails() { || ... } click to toggle source

Code to be executed only inside of a rails app

# File lib/rails_agnostic_models/rails_helpers.rb, line 43
def rails(&block)
  return nil unless rails_loaded
  yield
end
rails_2() { || ... } click to toggle source

Takes a block that will only be executed in a Rails 2 Project

# File lib/rails_agnostic_models/rails_helpers.rb, line 25
def rails_2(&block)
  return nil unless rails_2?
  yield
end
rails_2?() click to toggle source

Checks if the host app is a Rails 2 app

# File lib/rails_agnostic_models/rails_helpers.rb, line 5
def rails_2?
  rails_loaded && (Rails::VERSION::MAJOR == 2)
end
rails_3() { || ... } click to toggle source

Code to be executed insode of a Rails 3 app

# File lib/rails_agnostic_models/rails_helpers.rb, line 31
def rails_3(&block)
  return nil unless rails_3?
  yield
end
rails_3?() click to toggle source

Checks if the host app is a Rails 3 app

# File lib/rails_agnostic_models/rails_helpers.rb, line 10
def rails_3?
  rails_loaded && (Rails::VERSION::MAJOR == 3)
end
rails_4() { || ... } click to toggle source

Code to be executed inside of a Rails 4 app

# File lib/rails_agnostic_models/rails_helpers.rb, line 37
def rails_4(&block)
  return nil unless rails_4?
  yield
end
rails_4?() click to toggle source

Checks if the host app is a Rails 4 app

# File lib/rails_agnostic_models/rails_helpers.rb, line 15
def rails_4?
  rails_loaded && (Rails::VERSION::MAJOR == 4)
end
rails_loaded() click to toggle source

Checks if Rails is loaded

# File lib/rails_agnostic_models/rails_helpers.rb, line 20
def rails_loaded
  defined? Rails
end