Module: Variants::Helpers::InstanceMethods

Defined in:
lib/variants/helpers.rb

Instance Method Summary collapse

Instance Method Details

#variant(name, *args) ⇒ Object Also known as: v



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/variants/helpers.rb', line 8

def variant name, *args

  # If Rails env is development
  if Rails.env.development?
    # Override conditions if params[:variant_name] is presented
    unless self.params[name].nil?
      return self.params[name].to_s == 'true'
    end
  end

  # If block is given
  if block_given?
    return yield(*args)
  end

  # Try to call condition method
  return self.send(name, *args)
end