Sha256: c18d3b0071c33d7776d286a100ed967c8863f570fd16b5ffb7f975a07b2d2893

Contents?: true

Size: 535 Bytes

Versions: 6

Compression:

Stored size: 535 Bytes

Contents

# frozen_string_literal: true

class ActWithFlags::Admin
  attr_reader :model, :ranges

  def initialize(model)
    @locations = {}
    @clears = {}
    @ranges = {}
    @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

6 entries across 6 versions & 1 rubygems

Version Path
act_with_flags-3.1.9 lib/act_with_flags/admin.rb
act_with_flags-3.1.6 lib/act_with_flags/admin.rb
act_with_flags-3.1.5 lib/act_with_flags/admin.rb
act_with_flags-3.1.3 lib/act_with_flags/admin.rb
act_with_flags-3.1.2 lib/act_with_flags/admin.rb
act_with_flags-3.1.1 lib/act_with_flags/admin.rb