Sha256: 6c9e32f7bfcb689d501fee34dfe5fd3bd9d867c64d81b3b897e50eb7fb6eff5c

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

require 'commands/init/init_model'

module Commands
  module Init
    class GroupModel < InitModel
      inheritable_attributes :group, :max_results, :max_scan_rows,
                             :max_lock_time, :password_timeout, :timeout,
                             :users, :subgroups, :owners


      @group = nil
      @max_results = nil
      @max_scan_rows = nil
      @max_lock_time = nil
      @timeout = nil
      @password_timeout = nil
      @users = nil
      @subgroups = nil
      @owners = nil

      def self.abstract
        true
      end

      def initialize
        @group = self.class.group
        @max_results = self.class.max_results
        @max_scan_rows = self.class.max_scan_rows
        @timeout = self.class.timeout
        @password_timeout = self.class.password_timeout
        @users = self.class.users
        @subgroups = self.class.subgroups
        @owners = self.class.owners
      end

      def to_spec
        spec = {
            'Group' => @group
        }

        spec['MaxResults'] = @max_results unless @max_results.nil?
        spec['MaxScanRows'] = @max_scan_rows unless @max_scan_rows.nil?
        spec['MaxLockTime'] = @max_lock_time unless @max_lock_time.nil?
        spec['Timeout'] = @timeout unless @timeout.nil?
        spec['PasswordTimeout'] = @password_timeout unless @password_timeout.nil?
        spec['Users'] = @users unless @users.nil?
        spec['Subgroups'] = @subgroups unless @subgroups.nil?
        spec['Owners'] = @owners unless @owners.nil?

        spec
      end

      def execute(p4, models=nil, super_user=nil)
        puts "group: #{to_spec}"
        p4.save_group(to_spec)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
p4util-0.4.3 ./lib/commands/init/group_model.rb
p4util-0.4.2 ./lib/commands/init/group_model.rb
p4util-0.4.1 ./lib/commands/init/group_model.rb
p4util-0.4 ./lib/commands/init/group_model.rb
p4util-0.3.1 ./lib/commands/init/group_model.rb
p4util-0.3.0 ./lib/commands/init/group_model.rb
p4util-0.2 ./lib/commands/init/group_model.rb