Class: ElectricProfile::RespondentProfiler

Inherits:
Object
  • Object
show all
Defined in:
lib/electric_profile_ruby/respondent_profiler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(atts) ⇒ RespondentProfiler

Returns a new instance of RespondentProfiler.



6
7
8
9
10
# File 'lib/electric_profile_ruby/respondent_profiler.rb', line 6

def initialize(atts)
  atts = atts.inject({}){ |memo, (k, v) | memo[k.to_sym] = v; memo }
  @questions = atts[:questions]
  @profiler = atts[:profiler]
end

Instance Attribute Details

#profilerObject

Returns the value of attribute profiler.



4
5
6
# File 'lib/electric_profile_ruby/respondent_profiler.rb', line 4

def profiler
  @profiler
end

#questionsObject

Returns the value of attribute questions.



4
5
6
# File 'lib/electric_profile_ruby/respondent_profiler.rb', line 4

def questions
  @questions
end

Class Method Details

.find(profiler_id, user_id, locale) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/electric_profile_ruby/respondent_profiler.rb', line 20

def self.find(profiler_id, user_id, locale)
  client = Client.new
  if client.fetch_respondent_profiler(profiler_id, user_id, locale)
    new client.data
  else
    raise StandardError, client.error
  end
end

Instance Method Details

#saveObject



12
13
14
15
16
17
18
# File 'lib/electric_profile_ruby/respondent_profiler.rb', line 12

def save
  if @id
    save_existing
  else
    save_new
  end
end