Class: LaunchDarkly::Impl::Model::Clause

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/impl/model/clause.rb

Overview

Since:

  • 5.5.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, errors_out = nil) ⇒ Clause

Returns a new instance of Clause.

Since:

  • 5.5.0



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ldclient-rb/impl/model/clause.rb', line 10

def initialize(data, errors_out = nil)
  @data = data
  @context_kind = data[:contextKind]
  @op = data[:op].to_sym
  if @op == :segmentMatch
    @attribute = nil
  else
    @attribute = (@context_kind.nil? || @context_kind.empty?) ? Reference.create_literal(data[:attribute]) : Reference.create(data[:attribute])
    unless errors_out.nil? || @attribute.error.nil?
      errors_out << "clause has invalid attribute: #{@attribute.error}"
    end
  end
  @values = data[:values] || []
  @negate = !!data[:negate]
end

Instance Attribute Details

#attributeLaunchDarkly::Reference (readonly)

Returns:

Since:

  • 5.5.0



31
32
33
# File 'lib/ldclient-rb/impl/model/clause.rb', line 31

def attribute
  @attribute
end

#context_kindString|nil (readonly)

Returns:

  • (String|nil)

Since:

  • 5.5.0



29
30
31
# File 'lib/ldclient-rb/impl/model/clause.rb', line 29

def context_kind
  @context_kind
end

#dataHash (readonly)

Returns:

  • (Hash)

Since:

  • 5.5.0



27
28
29
# File 'lib/ldclient-rb/impl/model/clause.rb', line 27

def data
  @data
end

#negateBoolean (readonly)

Returns:

  • (Boolean)

Since:

  • 5.5.0



37
38
39
# File 'lib/ldclient-rb/impl/model/clause.rb', line 37

def negate
  @negate
end

#opSymbol (readonly)

Returns:

  • (Symbol)

Since:

  • 5.5.0



33
34
35
# File 'lib/ldclient-rb/impl/model/clause.rb', line 33

def op
  @op
end

#valuesArray (readonly)

Returns:

  • (Array)

Since:

  • 5.5.0



35
36
37
# File 'lib/ldclient-rb/impl/model/clause.rb', line 35

def values
  @values
end

Instance Method Details

#as_jsonObject

Since:

  • 5.5.0



39
40
41
# File 'lib/ldclient-rb/impl/model/clause.rb', line 39

def as_json
  @data
end