Class: Comet::FileOption

Inherits:
Object
  • Object
show all
Defined in:
lib/comet/models/file_option.rb

Overview

This type is available in Comet 23.3.7 and later.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFileOption

Returns a new instance of FileOption.



44
45
46
# File 'lib/comet/models/file_option.rb', line 44

def initialize
  clear
end

Instance Attribute Details

#allow_event_typesObject

Configure a subset of allowed event types (see SEVT_ constants). If the array is empty, all events will be sent



26
27
28
# File 'lib/comet/models/file_option.rb', line 26

def allow_event_types
  @allow_event_types
end

#filenameObject

The prefix for the log filename. It will be stored in the same file location as the Comet Server log files



21
22
23
# File 'lib/comet/models/file_option.rb', line 21

def filename
  @filename
end

#levelObject

One of the STREAM_LEVEL_ constants. This controls how much data is logged into the file



30
31
32
# File 'lib/comet/models/file_option.rb', line 30

def level
  @level
end

#pruning_enabledObject

Enables pruning of log files



34
35
36
# File 'lib/comet/models/file_option.rb', line 34

def pruning_enabled
  @pruning_enabled
end

#pruning_limitObject

Limit in days to keep log files when PruningEnabled is set to true. If not set or 0, uses server’s PruneLogsAfterDays



39
40
41
# File 'lib/comet/models/file_option.rb', line 39

def pruning_limit
  @pruning_limit
end

#unknown_json_fieldsObject

Returns the value of attribute unknown_json_fields.



42
43
44
# File 'lib/comet/models/file_option.rb', line 42

def unknown_json_fields
  @unknown_json_fields
end

Instance Method Details

#clearObject



48
49
50
51
52
53
54
# File 'lib/comet/models/file_option.rb', line 48

def clear
  @filename = ''
  @allow_event_types = []
  @level = ''
  @pruning_limit = 0
  @unknown_json_fields = {}
end

#from_hash(obj) ⇒ Object

Parameters:

  • obj (Hash)

    The complete object as a Ruby hash

Raises:

  • (TypeError)


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/comet/models/file_option.rb', line 64

def from_hash(obj)
  raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash

  obj.each do |k, v|
    case k
    when 'Filename'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @filename = v
    when 'AllowEventTypes'
      if v.nil?
        @allow_event_types = []
      else
        @allow_event_types = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected Numeric, got #{v1.class}" unless v1.is_a? Numeric

          @allow_event_types[i1] = v1
        end
      end
    when 'Level'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @level = v
    when 'PruningEnabled'
      @pruning_enabled = v
    when 'PruningLimit'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @pruning_limit = v
    else
      @unknown_json_fields[k] = v
    end
  end
end

#from_json(json_string) ⇒ Object

Parameters:

  • json_string (String)

    The complete object in JSON format

Raises:

  • (TypeError)


57
58
59
60
61
# File 'lib/comet/models/file_option.rb', line 57

def from_json(json_string)
  raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String

  from_hash(JSON.parse(json_string))
end

#to_hHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



123
124
125
# File 'lib/comet/models/file_option.rb', line 123

def to_h
  to_hash
end

#to_hashHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/comet/models/file_option.rb', line 101

def to_hash
  ret = {}
  ret['Filename'] = @filename
  unless @allow_event_types.nil?
    ret['AllowEventTypes'] = @allow_event_types
  end
  unless @level.nil?
    ret['Level'] = @level
  end
  unless @pruning_enabled.nil?
    ret['PruningEnabled'] = @pruning_enabled
  end
  unless @pruning_limit.nil?
    ret['PruningLimit'] = @pruning_limit
  end
  @unknown_json_fields.each do |k, v|
    ret[k] = v
  end
  ret
end

#to_json(options = {}) ⇒ String

Returns The complete object as a JSON string.

Returns:

  • (String)

    The complete object as a JSON string



128
129
130
# File 'lib/comet/models/file_option.rb', line 128

def to_json(options = {})
  to_hash.to_json(options)
end