Class: Mass::EnrichmentType

Inherits:
BlackStack::Base
  • Object
show all
Defined in:
lib/base-line/enrichment_type.rb

Overview

Enrichment module. List of methods you have to overload if you develop a profile type that supports enrichment operations.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.object_nameObject



6
7
8
# File 'lib/base-line/enrichment_type.rb', line 6

def self.object_name
    'enrichment_type'
end

Instance Method Details

#normalized_enrichment_url(url:) ⇒ Object

Return the same URL in a normalized form:

  • remove all GET parameters.

  • remove all trailing slashes.

If the profile ‘access` is not `:rpa`, raise an exception. If the `url` is not valid, raise an exception. Return the normalized URL.

Overload this method in the child class.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/base-line/enrichment_type.rb', line 34

def normalized_enrichment_url(url:)
    # If the profile `access` is not `:rpa`, raise an exception.
    raise "The method `normalized_enrichment_url` is not allowed for #{self.access.to_s} access." if self.access != :rpa
    # Return the same URL in a normalized form:
    # - remove all GET parameters.
    # - remove all trailing slashes.
    url = url.gsub(/\?.*$/, '').strip
    url = ret.gsub(/\/+$/, '')
    # Return the normalized URL.
    url
end

#valid_enrichment_params?(params:) ⇒ Boolean

If the profile ‘access` is not `:api`, raise an exception. Parameter `params` must be a hash. Return `true` if the `params` are valid. Return `false` if the `params` are not valid.

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
58
# File 'lib/base-line/enrichment_type.rb', line 50

def valid_enrichment_params?(params:)
    # If the profile `access` is not `:api`, raise an exception.
    raise "The method `valid_enrichment_params?` is not allowed for #{self.access.to_s} access." if self.access != :api
    # Parameter `params` must be a hash.
    raise "The parameter `params` must be a hash." if !params.is_a?(Hash)
    # Return `true` if the `params` are valid.
    # Return `false` if the `params` are not valid. 
    true
end

#valid_enrichment_url?(url:) ⇒ Boolean

If the profile ‘access` is not `:rpa`, raise an exception. Return `true` if the `url` is valid. Return `false` if the `url` is not valid.

Overload this method in the child class.

Returns:

  • (Boolean)


16
17
18
19
20
21
22
# File 'lib/base-line/enrichment_type.rb', line 16

def valid_enrichment_url?(url:)
    # If the profile `access` is not `:rpa`, raise an exception.
    raise "The method `valid_enrichment_url?` is not allowed for #{self.access.to_s} access." if self.access != :rpa
    # Return `true` if the `url` is valid.
    # Return `false` if the `url` is not valid. 
    true
end