Class: RecombeeApiClient::Logic

Inherits:
Input
  • Object
show all
Defined in:
lib/recombee_api_client/inputs/logic.rb

Overview

Initializes Logic input#

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashNormalizer

#camelize, #normalize_hash_to_camel_case

Constructor Details

#initialize(optional = {}) ⇒ Logic

  • *Optional arguments (given as hash optional)*

    • name -> Name of the logic that should be used

    • settings -> Parameters passed to the logic



22
23
24
25
26
27
28
29
30
# File 'lib/recombee_api_client/inputs/logic.rb', line 22

def initialize(optional = {})
  optional = normalize_hash_to_camel_case(optional)
  @name = optional['name']
  @settings = optional['settings']
  @optional = optional
  @optional.each do |par, _|
    raise UnknownOptionalParameter.new(par) unless %w[name settings].include? par
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/recombee_api_client/inputs/logic.rb', line 14

def name
  @name
end

#settingsObject (readonly)

Returns the value of attribute settings.



14
15
16
# File 'lib/recombee_api_client/inputs/logic.rb', line 14

def settings
  @settings
end

Instance Method Details

#as_json(_options = {}) ⇒ Object

Return only JSON-serializable primitives.



33
34
35
36
37
38
39
# File 'lib/recombee_api_client/inputs/logic.rb', line 33

def as_json(_options = {})
  res = {}
  res['name'] = @optional['name'] if @optional['name']
  res['settings'] = @optional['settings'] if @optional['settings']

  res
end

#to_json(*args) ⇒ Object



41
42
43
# File 'lib/recombee_api_client/inputs/logic.rb', line 41

def to_json(*args)
  as_json.to_json(*args)
end