Class: Mass::Enrichment
- Inherits:
-
BlackStack::Base
- Object
- BlackStack::Base
- Mass::Enrichment
- Defined in:
- lib/base-line/enrichment.rb
Instance Attribute Summary collapse
-
#company ⇒ Object
Returns the value of attribute company.
-
#lead ⇒ Object
Returns the value of attribute lead.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#profile_type ⇒ Object
Returns the value of attribute profile_type.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#child_class_instance ⇒ Object
crate an instance of the profile type using the class defined in the ‘desc` attribute.
-
#class_name_from_enrichment_type ⇒ Object
convert the enrichment_type into the ruby class to create an instance.
-
#do(logger: nil) ⇒ Object
Update the lead or company with new information.
-
#initialize(h) ⇒ Enrichment
constructor
A new instance of Enrichment.
Constructor Details
#initialize(h) ⇒ Enrichment
Returns a new instance of Enrichment.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/base-line/enrichment.rb', line 9 def initialize(h) super(h) self.type = Mass::EnrichmentType.new(h['enrichment_type_desc']) if h['enrichment_type_desc'] self.profile = Mass::Profile.new(h['profile']).child_class_instance if h['profile'] self.lead = Mass::Lead.new(h['lead']) if h['lead'] self.company = Mass::Company.new(h['company']) if h['company'] self.profile_type = Mass::ProfileType.page( id_account: h['id_account'], page: 1, limit: 1, filters: { name: h['profile_type'] } ).first.child_class_instance if h['profile_type'] end |
Instance Attribute Details
#company ⇒ Object
Returns the value of attribute company.
3 4 5 |
# File 'lib/base-line/enrichment.rb', line 3 def company @company end |
#lead ⇒ Object
Returns the value of attribute lead.
3 4 5 |
# File 'lib/base-line/enrichment.rb', line 3 def lead @lead end |
#profile ⇒ Object
Returns the value of attribute profile.
3 4 5 |
# File 'lib/base-line/enrichment.rb', line 3 def profile @profile end |
#profile_type ⇒ Object
Returns the value of attribute profile_type.
3 4 5 |
# File 'lib/base-line/enrichment.rb', line 3 def profile_type @profile_type end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/base-line/enrichment.rb', line 3 def type @type end |
Class Method Details
.object_name ⇒ Object
5 6 7 |
# File 'lib/base-line/enrichment.rb', line 5 def self.object_name 'enrichment' end |
Instance Method Details
#child_class_instance ⇒ Object
crate an instance of the profile type using the class defined in the ‘desc` attribute. override the base method
34 35 36 37 38 39 40 |
# File 'lib/base-line/enrichment.rb', line 34 def child_class_instance enrichment_type = self.desc['enrichment_type'] key = self.class_name_from_enrichment_type raise "Source code of enrichment type #{enrichment_type} not found. Create a class #{key} in the folder `/lib` of your mass-sdk." unless Kernel.const_defined?(key) ret = Kernel.const_get(key).new(self.desc) return ret end |
#class_name_from_enrichment_type ⇒ Object
convert the enrichment_type into the ruby class to create an instance. example: Apollo –> Mass::ApolloAPI
27 28 29 30 |
# File 'lib/base-line/enrichment.rb', line 27 def class_name_from_enrichment_type enrichment_type = self.desc['enrichment_type'] "Mass::#{enrichment_type}" end |
#do(logger: nil) ⇒ Object
Update the lead or company with new information.
44 45 46 47 48 |
# File 'lib/base-line/enrichment.rb', line 44 def do( logger:nil ) # TODO: Code Me! end |