Class: MarkLogic::DatabaseSettings::RangeElementIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/marklogic/database_settings/range_element_index.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ RangeElementIndex

Returns a new instance of RangeElementIndex.


7
8
9
10
11
12
13
14
15
# File 'lib/marklogic/database_settings/range_element_index.rb', line 7

def initialize(name, options = {})
  @scalar_type = options[:type] || 'string'
  @localname = name.to_s
  @namespace_uri = options[:namespace] || ""
  @collation = options[:collation] || (@scalar_type == 'string' ? MarkLogic::DEFAULT_COLLATION : "")
  @range_value_positions = options[:range_value_positions] || false
  @invalid_values = options[:invalid_values] || MarkLogic::REJECT
  @facet = options[:facet] || false
end

Instance Attribute Details

#collationObject

Returns the value of attribute collation


5
6
7
# File 'lib/marklogic/database_settings/range_element_index.rb', line 5

def collation
  @collation
end

#facetObject

Returns the value of attribute facet


5
6
7
# File 'lib/marklogic/database_settings/range_element_index.rb', line 5

def facet
  @facet
end

#invalid_valuesObject

Returns the value of attribute invalid_values


5
6
7
# File 'lib/marklogic/database_settings/range_element_index.rb', line 5

def invalid_values
  @invalid_values
end

#localnameObject

Returns the value of attribute localname


5
6
7
# File 'lib/marklogic/database_settings/range_element_index.rb', line 5

def localname
  @localname
end

#namespace_uriObject

Returns the value of attribute namespace_uri


5
6
7
# File 'lib/marklogic/database_settings/range_element_index.rb', line 5

def namespace_uri
  @namespace_uri
end

#range_value_positionsObject

Returns the value of attribute range_value_positions


5
6
7
# File 'lib/marklogic/database_settings/range_element_index.rb', line 5

def range_value_positions
  @range_value_positions
end

#scalar_typeObject

Returns the value of attribute scalar_type


5
6
7
# File 'lib/marklogic/database_settings/range_element_index.rb', line 5

def scalar_type
  @scalar_type
end

Class Method Details

.from_json(json) ⇒ Object


60
61
62
63
64
# File 'lib/marklogic/database_settings/range_element_index.rb', line 60

def self.from_json(json)
  index = allocate
  index.from_json(json)
  index
end

Instance Method Details

#<=>(other) ⇒ Object


21
22
23
# File 'lib/marklogic/database_settings/range_element_index.rb', line 21

def <=>(other)
  localname <=> other.localname
end

#==(other) ⇒ Object


25
26
27
28
29
30
31
32
33
# File 'lib/marklogic/database_settings/range_element_index.rb', line 25

def ==(other)
  self.class == other.class and
  scalar_type == other.scalar_type and
  localname = other.localname and
  namespace_uri = other.namespace_uri and
  collation == other.collation and
  range_value_positions == other.range_value_positions and
  invalid_values == other.invalid_values
end

#append_to_db(database) ⇒ Object


39
40
41
# File 'lib/marklogic/database_settings/range_element_index.rb', line 39

def append_to_db(database)
  database.add_index("range-element-index", self)
end

#from_json(json) ⇒ Object


66
67
68
69
70
71
72
73
74
# File 'lib/marklogic/database_settings/range_element_index.rb', line 66

def from_json(json)
  @scalar_type = json['scalar-type']
  @namespace_uri = json['namespace-uri']
  @localname = json['localname']
  @collation = json['collation']
  @range_value_positions = json['range-value-positions']
  @invalid_values = json['invalid-values']
  @facet = false
end

#keyObject


17
18
19
# File 'lib/marklogic/database_settings/range_element_index.rb', line 17

def key
  %Q{#{self.class.to_s}-#{@localname}}
end

#to_json(options = nil) ⇒ Object


43
44
45
46
47
48
49
50
51
52
# File 'lib/marklogic/database_settings/range_element_index.rb', line 43

def to_json(options = nil)
  {
    "scalar-type" => @scalar_type,
    "namespace-uri" => @namespace_uri,
    "localname" => @localname,
    "collation" => @collation,
    "range-value-positions" => @range_value_positions,
    "invalid-values" => @invalid_values
  }
end

#to_refObject


54
55
56
57
58
# File 'lib/marklogic/database_settings/range_element_index.rb', line 54

def to_ref
  options = [%Q{"type=#{@scalar_type}"}]
  options << %Q{"collation=#{@collation}"} if @scalar_type == "string"
  %Q{cts:json-property-reference("#{@localname}", (#{options.join(',')}))}
end

#typeObject


35
36
37
# File 'lib/marklogic/database_settings/range_element_index.rb', line 35

def type
  "range-element-index"
end