Sha256: 18f54cb40363e65319dcf0aa1c20a2417ed910dcc863410fd7ef597980b85430

Contents?: true

Size: 460 Bytes

Versions: 26

Compression:

Stored size: 460 Bytes

Contents

module VariableHelpers
  def set(key, value)
    @_data ||= {}
    @_data[key] = value
  end

  def selected?(key, value = nil)
    value ? equals?(key, value) : get(key)
  end

  def get(key)
    @_data ||= {}
    @_data[key]
  end

  def equals?(key, value)
    get(key) == value
  end

  def exists?(key)
    equals?("#{key}_exists".to_sym, true)
  end

  private

  def ensure_variable(key, default_value)
    set(key, get(key) || default_value)
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
potassium-7.2.0 lib/potassium/helpers/variable-helpers.rb
potassium-7.1.0 lib/potassium/helpers/variable-helpers.rb
potassium-7.0.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.7.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.6.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.5.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.4.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.3.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.2.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.1.0 lib/potassium/helpers/variable-helpers.rb
potassium-6.0.0 lib/potassium/helpers/variable-helpers.rb
potassium-5.2.3 lib/potassium/helpers/variable-helpers.rb
potassium-5.2.2 lib/potassium/helpers/variable-helpers.rb
potassium-5.2.1 lib/potassium/helpers/variable-helpers.rb
potassium-5.2.0 lib/potassium/helpers/variable-helpers.rb
potassium-5.1.4 lib/potassium/helpers/variable-helpers.rb
potassium-5.1.3 lib/potassium/helpers/variable-helpers.rb
potassium-5.1.2 lib/potassium/helpers/variable-helpers.rb
potassium-5.1.1 lib/potassium/helpers/variable-helpers.rb
potassium-3.0.0 lib/potassium/helpers/variable-helpers.rb