Module: RailsAgnosticModels::RailsVersionHelpers::ClassMethods

Defined in:
lib/rails_agnostic_models/rails_version_helpers.rb

Instance Method Summary collapse

Instance Method Details

#rails_2(&block) ⇒ Object

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



20
21
22
23
# File 'lib/rails_agnostic_models/rails_version_helpers.rb', line 20

def rails_2(&block)
  return nil unless rails_2?
  yield
end

#rails_2?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/rails_agnostic_models/rails_version_helpers.rb', line 7

def rails_2?
  (defined? Rails) && (Rails::VERSION::MAJOR == 2)
end

#rails_3(&block) ⇒ Object



25
26
27
28
# File 'lib/rails_agnostic_models/rails_version_helpers.rb', line 25

def rails_3(&block)
  return nil unless rails_3?
  yield
end

#rails_3?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rails_agnostic_models/rails_version_helpers.rb', line 11

def rails_3?
  (defined? Rails) && (Rails::VERSION::MAJOR == 3)
end

#rails_4(&block) ⇒ Object



30
31
32
33
# File 'lib/rails_agnostic_models/rails_version_helpers.rb', line 30

def rails_4(&block)
  return nil unless rails_4?
  yield
end

#rails_4?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rails_agnostic_models/rails_version_helpers.rb', line 15

def rails_4?
  (defined? Rails) && (Rails::VERSION::MAJOR == 4)
end