Class: Paraphrase::Mapping Private

Inherits:
Object
  • Object
show all
Defined in:
lib/paraphrase/mapping.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keys, options) ⇒ Mapping

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Mapping.



8
9
10
11
12
13
14
15
16
17
# File 'lib/paraphrase/mapping.rb', line 8

def initialize(keys, options)
  @keys = keys
  @name = options[:to]

  @required_keys = if options[:whitelist] == true
    []
  else
    @keys - Array.wrap(options[:whitelist])
  end
end

Instance Attribute Details

#keysObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/paraphrase/mapping.rb', line 6

def keys
  @keys
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/paraphrase/mapping.rb', line 6

def name
  @name
end

#required_keysObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/paraphrase/mapping.rb', line 6

def required_keys
  @required_keys
end

Instance Method Details

#satisfied?(params) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


19
20
21
# File 'lib/paraphrase/mapping.rb', line 19

def satisfied?(params)
  required_keys.all? { |key| params[key] }
end

#values(params) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/paraphrase/mapping.rb', line 23

def values(params)
  keys.map { |key| params[key] }
end