Sha256: 74967799e05b4b24d6d755aa2fdec7fa1ae6c9d34738c8e8d4e7a3ffc4367094

Contents?: true

Size: 509 Bytes

Versions: 2

Compression:

Stored size: 509 Bytes

Contents

# frozen_string_literal: true

class ActWithFlags::Admin
  attr_reader :model

  def initialize(model)
    @locations = {}
    @clears = {}
    @model = model
    @boolean_hash = {}
    [true, "true", 1, "1"].each { |x| @boolean_hash[x] = true }
    [false, "false", 0, "0"].each { |x| @boolean_hash[x] = false }
  end

  def reset_model(model)
    initialize model
  end

  def to_boolean(value)
    res = @boolean_hash[value]
    return res unless res.nil?

    raise "invalid boolean <#{value}>"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
act_with_flags-3.1.0 lib/act_with_flags/admin.rb
act_with_flags-3.0.1 lib/act_with_flags/admin.rb