ovirt_metrics 1.4.0 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +0 -1
- data/lib/active_record/connection_adapters/ovirt_postgresql_adapter.rb +30 -0
- data/lib/ovirt_metrics.rb +9 -9
- data/lib/ovirt_metrics/column_definitions.rb +4 -4
- data/lib/ovirt_metrics/models/host_configuration.rb +0 -14
- data/lib/ovirt_metrics/models/host_samples_history.rb +1 -1
- data/lib/ovirt_metrics/models/vm_device_history.rb +1 -0
- data/lib/ovirt_metrics/models/vm_samples_history.rb +1 -1
- data/lib/ovirt_metrics/version.rb +1 -1
- data/spec/models/host_samples_history_spec.rb +10 -10
- data/spec/models/vm_disk_samples_history_spec.rb +4 -4
- data/spec/models/vm_samples_history_spec.rb +3 -8
- data/spec/ovirt_metrics_spec.rb +30 -0
- data/spec/support/active_record.rb +0 -6
- metadata +15 -58
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/column.rb +0 -15
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/database_statements.rb +0 -170
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/explain_pretty_printer.rb +0 -42
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid.rb +0 -31
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/array.rb +0 -70
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit.rb +0 -52
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit_varying.rb +0 -13
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bytea.rb +0 -15
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/cidr.rb +0 -48
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/date_time.rb +0 -21
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/decimal.rb +0 -13
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/enum.rb +0 -19
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/hstore.rb +0 -59
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/inet.rb +0 -13
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/json.rb +0 -10
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/jsonb.rb +0 -23
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/money.rb +0 -39
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/point.rb +0 -43
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/rails_5_1_point.rb +0 -50
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/range.rb +0 -93
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/specialized_string.rb +0 -15
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/type_map_initializer.rb +0 -109
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/uuid.rb +0 -21
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/vector.rb +0 -26
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/xml.rb +0 -28
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/quoting.rb +0 -116
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/referential_integrity.rb +0 -49
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_definitions.rb +0 -180
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_dumper.rb +0 -47
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_statements.rb +0 -682
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/type_metadata.rb +0 -35
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/utils.rb +0 -77
- data/lib/active_record/connection_adapters/ovirt_legacy_postgresql_adapter.rb +0 -856
- data/spec/models/host_configuration_spec.rb +0 -31
- data/spec/schemas/schema_rhev30.rb +0 -655
@@ -1,21 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class DateTime < Type::DateTime # :nodoc:
|
6
|
-
def cast_value(value)
|
7
|
-
case value
|
8
|
-
when 'infinity' then ::Float::INFINITY
|
9
|
-
when '-infinity' then -::Float::INFINITY
|
10
|
-
when / BC$/
|
11
|
-
astronomical_year = format("%04d", -value[/^\d+/].to_i + 1)
|
12
|
-
super(value.sub(/ BC$/, "").sub(/^\d+/, astronomical_year))
|
13
|
-
else
|
14
|
-
super
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class Decimal < Type::Decimal # :nodoc:
|
6
|
-
def infinity(options = {})
|
7
|
-
BigDecimal.new("Infinity") * (options[:negative] ? -1 : 1)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class Enum < Type::Value # :nodoc:
|
6
|
-
def type
|
7
|
-
:enum
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def cast_value(value)
|
13
|
-
value.to_s
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class Hstore < Type::Value # :nodoc:
|
6
|
-
include Type::Helpers::Mutable
|
7
|
-
|
8
|
-
def type
|
9
|
-
:hstore
|
10
|
-
end
|
11
|
-
|
12
|
-
def deserialize(value)
|
13
|
-
if value.is_a?(::String)
|
14
|
-
::Hash[value.scan(HstorePair).map { |k, v|
|
15
|
-
v = v.upcase == 'NULL' ? nil : v.gsub(/\A"(.*)"\Z/m,'\1').gsub(/\\(.)/, '\1')
|
16
|
-
k = k.gsub(/\A"(.*)"\Z/m,'\1').gsub(/\\(.)/, '\1')
|
17
|
-
[k, v]
|
18
|
-
}]
|
19
|
-
else
|
20
|
-
value
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def serialize(value)
|
25
|
-
if value.is_a?(::Hash)
|
26
|
-
value.map { |k, v| "#{escape_hstore(k)}=>#{escape_hstore(v)}" }.join(', ')
|
27
|
-
else
|
28
|
-
value
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def accessor
|
33
|
-
ActiveRecord::Store::StringKeyedHashAccessor
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
HstorePair = begin
|
39
|
-
quoted_string = /"[^"\\]*(?:\\.[^"\\]*)*"/
|
40
|
-
unquoted_string = /(?:\\.|[^\s,])[^\s=,\\]*(?:\\.[^\s=,\\]*|=[^,>])*/
|
41
|
-
/(#{quoted_string}|#{unquoted_string})\s*=>\s*(#{quoted_string}|#{unquoted_string})/
|
42
|
-
end
|
43
|
-
|
44
|
-
def escape_hstore(value)
|
45
|
-
if value.nil?
|
46
|
-
'NULL'
|
47
|
-
else
|
48
|
-
if value == ""
|
49
|
-
'""'
|
50
|
-
else
|
51
|
-
'"%s"' % value.to_s.gsub(/(["\\])/, '\\\\\1')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class Jsonb < Json # :nodoc:
|
6
|
-
def type
|
7
|
-
:jsonb
|
8
|
-
end
|
9
|
-
|
10
|
-
def changed_in_place?(raw_old_value, new_value)
|
11
|
-
# Postgres does not preserve insignificant whitespaces when
|
12
|
-
# round-tripping jsonb columns. This causes some false positives for
|
13
|
-
# the comparison here. Therefore, we need to parse and re-dump the
|
14
|
-
# raw value here to ensure the insignificant whitespaces are
|
15
|
-
# consistent with our encoder's output.
|
16
|
-
raw_old_value = serialize(deserialize(raw_old_value))
|
17
|
-
super(raw_old_value, new_value)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class Money < Type::Decimal # :nodoc:
|
6
|
-
def type
|
7
|
-
:money
|
8
|
-
end
|
9
|
-
|
10
|
-
def scale
|
11
|
-
2
|
12
|
-
end
|
13
|
-
|
14
|
-
def cast_value(value)
|
15
|
-
return value unless ::String === value
|
16
|
-
|
17
|
-
# Because money output is formatted according to the locale, there are two
|
18
|
-
# cases to consider (note the decimal separators):
|
19
|
-
# (1) $12,345,678.12
|
20
|
-
# (2) $12.345.678,12
|
21
|
-
# Negative values are represented as follows:
|
22
|
-
# (3) -$2.55
|
23
|
-
# (4) ($2.55)
|
24
|
-
|
25
|
-
value.sub!(/^\((.+)\)$/, '-\1') # (4)
|
26
|
-
case value
|
27
|
-
when /^-?\D+[\d,]+\.\d{2}$/ # (1)
|
28
|
-
value.gsub!(/[^-\d.]/, '')
|
29
|
-
when /^-?\D+[\d.]+,\d{2}$/ # (2)
|
30
|
-
value.gsub!(/[^-\d,]/, '').sub!(/,/, '.')
|
31
|
-
end
|
32
|
-
|
33
|
-
super(value)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class Point < Type::Value # :nodoc:
|
6
|
-
include Type::Helpers::Mutable
|
7
|
-
|
8
|
-
def type
|
9
|
-
:point
|
10
|
-
end
|
11
|
-
|
12
|
-
def cast(value)
|
13
|
-
case value
|
14
|
-
when ::String
|
15
|
-
if value[0] == '(' && value[-1] == ')'
|
16
|
-
value = value[1...-1]
|
17
|
-
end
|
18
|
-
cast(value.split(','))
|
19
|
-
when ::Array
|
20
|
-
value.map { |v| Float(v) }
|
21
|
-
else
|
22
|
-
value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def serialize(value)
|
27
|
-
if value.is_a?(::Array)
|
28
|
-
"(#{number_for_point(value[0])},#{number_for_point(value[1])})"
|
29
|
-
else
|
30
|
-
super
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def number_for_point(number)
|
37
|
-
number.to_s.gsub(/\.0$/, '')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
Point = Struct.new(:x, :y)
|
3
|
-
|
4
|
-
module ConnectionAdapters
|
5
|
-
module OvirtLegacyPostgreSQL
|
6
|
-
module OID # :nodoc:
|
7
|
-
class Rails51Point < Type::Value # :nodoc:
|
8
|
-
include Type::Helpers::Mutable
|
9
|
-
|
10
|
-
def type
|
11
|
-
:point
|
12
|
-
end
|
13
|
-
|
14
|
-
def cast(value)
|
15
|
-
case value
|
16
|
-
when ::String
|
17
|
-
if value[0] == '(' && value[-1] == ')'
|
18
|
-
value = value[1...-1]
|
19
|
-
end
|
20
|
-
x, y = value.split(",")
|
21
|
-
build_point(x, y)
|
22
|
-
when ::Array
|
23
|
-
build_point(*value)
|
24
|
-
else
|
25
|
-
value
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def serialize(value)
|
30
|
-
if value.is_a?(ActiveRecord::Point)
|
31
|
-
"(#{number_for_point(value.x)},#{number_for_point(value.y)})"
|
32
|
-
else
|
33
|
-
super
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def number_for_point(number)
|
40
|
-
number.to_s.gsub(/\.0$/, '')
|
41
|
-
end
|
42
|
-
|
43
|
-
def build_point(x, y)
|
44
|
-
ActiveRecord::Point.new(Float(x), Float(y))
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/string/filters'
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module ConnectionAdapters
|
5
|
-
module OvirtLegacyPostgreSQL
|
6
|
-
module OID # :nodoc:
|
7
|
-
class Range < Type::Value # :nodoc:
|
8
|
-
attr_reader :subtype, :type
|
9
|
-
delegate :user_input_in_time_zone, to: :subtype
|
10
|
-
|
11
|
-
def initialize(subtype, type = :range)
|
12
|
-
@subtype = subtype
|
13
|
-
@type = type
|
14
|
-
end
|
15
|
-
|
16
|
-
def type_cast_for_schema(value)
|
17
|
-
value.inspect.gsub('Infinity', '::Float::INFINITY')
|
18
|
-
end
|
19
|
-
|
20
|
-
def cast_value(value)
|
21
|
-
return if value == 'empty'
|
22
|
-
return value unless value.is_a?(::String)
|
23
|
-
|
24
|
-
extracted = extract_bounds(value)
|
25
|
-
from = type_cast_single extracted[:from]
|
26
|
-
to = type_cast_single extracted[:to]
|
27
|
-
|
28
|
-
if !infinity?(from) && extracted[:exclude_start]
|
29
|
-
raise ArgumentError, "The Ruby Range object does not support excluding the beginning of a Range. (unsupported value: '#{value}')"
|
30
|
-
end
|
31
|
-
::Range.new(from, to, extracted[:exclude_end])
|
32
|
-
end
|
33
|
-
|
34
|
-
def serialize(value)
|
35
|
-
if value.is_a?(::Range)
|
36
|
-
from = type_cast_single_for_database(value.begin)
|
37
|
-
to = type_cast_single_for_database(value.end)
|
38
|
-
"[#{from},#{to}#{value.exclude_end? ? ')' : ']'}"
|
39
|
-
else
|
40
|
-
super
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def ==(other)
|
45
|
-
other.is_a?(Range) &&
|
46
|
-
other.subtype == subtype &&
|
47
|
-
other.type == type
|
48
|
-
end
|
49
|
-
|
50
|
-
def map(value) # :nodoc:
|
51
|
-
new_begin = yield(value.begin)
|
52
|
-
new_end = yield(value.end)
|
53
|
-
::Range.new(new_begin, new_end, value.exclude_end?)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def type_cast_single(value)
|
59
|
-
infinity?(value) ? value : @subtype.deserialize(value)
|
60
|
-
end
|
61
|
-
|
62
|
-
def type_cast_single_for_database(value)
|
63
|
-
infinity?(value) ? '' : @subtype.serialize(value)
|
64
|
-
end
|
65
|
-
|
66
|
-
def extract_bounds(value)
|
67
|
-
from, to = value[1..-2].split(',')
|
68
|
-
{
|
69
|
-
from: (value[1] == ',' || from == '-infinity') ? infinity(negative: true) : from,
|
70
|
-
to: (value[-2] == ',' || to == 'infinity') ? infinity : to,
|
71
|
-
exclude_start: (value[0] == '('),
|
72
|
-
exclude_end: (value[-1] == ')')
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
def infinity(negative: false)
|
77
|
-
if subtype.respond_to?(:infinity)
|
78
|
-
subtype.infinity(negative: negative)
|
79
|
-
elsif negative
|
80
|
-
-::Float::INFINITY
|
81
|
-
else
|
82
|
-
::Float::INFINITY
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def infinity?(value)
|
87
|
-
value.respond_to?(:infinite?) && value.infinite?
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/specialized_string.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
class SpecializedString < Type::String # :nodoc:
|
6
|
-
attr_reader :type
|
7
|
-
|
8
|
-
def initialize(type)
|
9
|
-
@type = type
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/type_map_initializer.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module ConnectionAdapters
|
3
|
-
module OvirtLegacyPostgreSQL
|
4
|
-
module OID # :nodoc:
|
5
|
-
# This class uses the data from PostgreSQL pg_type table to build
|
6
|
-
# the OID -> Type mapping.
|
7
|
-
# - OID is an integer representing the type.
|
8
|
-
# - Type is an OID::Type object.
|
9
|
-
# This class has side effects on the +store+ passed during initialization.
|
10
|
-
class TypeMapInitializer # :nodoc:
|
11
|
-
def initialize(store)
|
12
|
-
@store = store
|
13
|
-
end
|
14
|
-
|
15
|
-
def run(records)
|
16
|
-
nodes = records.reject { |row| @store.key? row['oid'].to_i }
|
17
|
-
mapped, nodes = nodes.partition { |row| @store.key? row['typname'] }
|
18
|
-
ranges, nodes = nodes.partition { |row| row['typtype'] == 'r'.freeze }
|
19
|
-
enums, nodes = nodes.partition { |row| row['typtype'] == 'e'.freeze }
|
20
|
-
domains, nodes = nodes.partition { |row| row['typtype'] == 'd'.freeze }
|
21
|
-
arrays, nodes = nodes.partition { |row| row['typinput'] == 'array_in'.freeze }
|
22
|
-
composites, nodes = nodes.partition { |row| row['typelem'].to_i != 0 }
|
23
|
-
|
24
|
-
mapped.each { |row| register_mapped_type(row) }
|
25
|
-
enums.each { |row| register_enum_type(row) }
|
26
|
-
domains.each { |row| register_domain_type(row) }
|
27
|
-
arrays.each { |row| register_array_type(row) }
|
28
|
-
ranges.each { |row| register_range_type(row) }
|
29
|
-
composites.each { |row| register_composite_type(row) }
|
30
|
-
end
|
31
|
-
|
32
|
-
def query_conditions_for_initial_load(type_map)
|
33
|
-
known_type_names = type_map.keys.map { |n| "'#{n}'" }
|
34
|
-
known_type_types = %w('r' 'e' 'd')
|
35
|
-
<<-SQL % [known_type_names.join(", "), known_type_types.join(", ")]
|
36
|
-
WHERE
|
37
|
-
t.typname IN (%s)
|
38
|
-
OR t.typtype IN (%s)
|
39
|
-
OR t.typinput = 'array_in(cstring,oid,integer)'::regprocedure
|
40
|
-
OR t.typelem != 0
|
41
|
-
SQL
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def register_mapped_type(row)
|
46
|
-
alias_type row['oid'], row['typname']
|
47
|
-
end
|
48
|
-
|
49
|
-
def register_enum_type(row)
|
50
|
-
register row['oid'], OID::Enum.new
|
51
|
-
end
|
52
|
-
|
53
|
-
def register_array_type(row)
|
54
|
-
register_with_subtype(row['oid'], row['typelem'].to_i) do |subtype|
|
55
|
-
OID::Array.new(subtype, row['typdelim'])
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def register_range_type(row)
|
60
|
-
register_with_subtype(row['oid'], row['rngsubtype'].to_i) do |subtype|
|
61
|
-
OID::Range.new(subtype, row['typname'].to_sym)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def register_domain_type(row)
|
66
|
-
if base_type = @store.lookup(row["typbasetype"].to_i)
|
67
|
-
register row['oid'], base_type
|
68
|
-
else
|
69
|
-
warn "unknown base type (OID: #{row["typbasetype"]}) for domain #{row["typname"]}."
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def register_composite_type(row)
|
74
|
-
if subtype = @store.lookup(row['typelem'].to_i)
|
75
|
-
register row['oid'], OID::Vector.new(row['typdelim'], subtype)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def register(oid, oid_type = nil, &block)
|
80
|
-
oid = assert_valid_registration(oid, oid_type || block)
|
81
|
-
if block_given?
|
82
|
-
@store.register_type(oid, &block)
|
83
|
-
else
|
84
|
-
@store.register_type(oid, oid_type)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def alias_type(oid, target)
|
89
|
-
oid = assert_valid_registration(oid, target)
|
90
|
-
@store.alias_type(oid, target)
|
91
|
-
end
|
92
|
-
|
93
|
-
def register_with_subtype(oid, target_oid)
|
94
|
-
if @store.key?(target_oid)
|
95
|
-
register(oid) do |_, *args|
|
96
|
-
yield @store.lookup(target_oid, *args)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def assert_valid_registration(oid, oid_type)
|
102
|
-
raise ArgumentError, "can't register nil type for OID #{oid}" if oid_type.nil?
|
103
|
-
oid.to_i
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|