# A ruby class representation of entries of db.protect class Protection attr_accessor :seq, :is_group, :user, :host, :perm, :map_flag, :depot_file def initialize(seq, is_group, user, host, perm, map_flag, depot_file) #Sequence in the protections table @seq = seq #Is group? 0 = user, 1 = group @is_group = is_group #Username @user = user #Host @host = host #Access level (integer) @perm = perm #0 = +, 1 = -, 2 = + (overlay) @map_flag = map_flag #Path in the depot @depot_file = depot_file end # Tests to see if another {Protection} is equal to this one. # @param [Protection] prot Protection to test against # @return [True, False] def ==(prot) if @seq == prot.seq && @is_group == prot.is_group && @user == prot.user && @host == prot.host && @perm == prot.perm && \ @map_flag == prot.map_flag && @depot_file == prot.depot_file return true end end # Return a json hash representation of this object # @param [Option] *a options # @return [Hash{Symbol => String, Integer}] def to_json(*a) { :name => self.class.name, :seq => @seq, :is_group => @is_group, :user => @user, :host => @host, :perm => @perm, :map_flag => @map_flag, :depot_file => @depot_file }.to_json(*a) end # Create a Protection object from json representation # @param [Hash{Symbol => String, Integer}] o json hash # @return [Protection] new protection object def json_create(o) new(o[:seq], o[:is_group], o[:user], o[:host], o[:perm], o[:map_flag], o[:depot_file]) end end