Sha256: 0e3b73d333368521a90a9bebec8457e32beeea3a357fac06a2c9b1a4b940eb95

Contents?: true

Size: 632 Bytes

Versions: 5

Compression:

Stored size: 632 Bytes

Contents

# frozen_string_literal: true

class ActWithBooleans::Admin
  Location = Struct.new(:model, :origin, :position)

  attr_reader :locations

  def position(name)
    @locations[name].position
  end

  private

  def add_to_locations(flag, location)
    who = "<#{flag}: #{location.origin}@#{location.position}>"
    raise "name already used #{who}" if @locations.key?(flag)
    bool = @locations.has_value?(location)
    raise "position already used #{who}" if bool
    @locations[flag] = location
  end

  def check_pos(pos)
    pos ||= @size

    raise "Position already in use" if pos < @size
    @size = pos + 1
    pos
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
act_with_booleans-0.0.5 lib/act_with_booleans/booleans.rb
act_with_booleans-0.0.4 lib/act_with_booleans/booleans.rb
act_with_booleans-0.0.3 lib/act_with_booleans/booleans.rb
act_with_booleans-0.0.2 lib/act_with_booleans/booleans.rb
act_with_booleans-0.0.1 lib/act_with_booleans/booleans.rb