Module: ActsAsDailycred::InstanceMethods
- Defined in:
- lib/dailycred/acts_as_dailycred.rb
Instance Method Summary collapse
- #connect_path(provider) ⇒ Object
-
#display_name ⇒ Object
deprecated, use @user.display.
- #fire_event(key, val = "") ⇒ Object
- #get_client ⇒ Object
- #referral_link(url) ⇒ Object
- #reset_password ⇒ Object
- #tag(tag) ⇒ Object
- #untag(tag) ⇒ Object
- #update_from_dailycred(dc) ⇒ Object
Instance Method Details
#connect_path(provider) ⇒ Object
74 75 76 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 74 def connect_path provider "/auth/dailycred?identity_provider=#{provider.to_s}" end |
#display_name ⇒ Object
deprecated, use @user.display
47 48 49 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 47 def display_name self.display end |
#fire_event(key, val = "") ⇒ Object
66 67 68 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 66 def fire_event key, val="" get_client.event self.uid, key, val end |
#get_client ⇒ Object
70 71 72 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 70 def get_client @dailycred ||= Dailycred::Client.new Rails.configuration.DAILYCRED_CLIENT_ID, Rails.configuration.DAILYCRED_SECRET_KEY end |
#referral_link(url) ⇒ Object
51 52 53 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 51 def referral_link url "https://www.dailycred.com/r/#{self.uid}?redirect_uri=#{url}" end |
#reset_password ⇒ Object
54 55 56 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 54 def reset_password get_client.reset_password self.email end |
#tag(tag) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 26 def tag tag dc = get_client response = dc.tag self.uid, tag json = JSON.parse(response.body) if json['worked'] self. << tag save! end end |
#untag(tag) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 36 def untag tag dc = get_client response = dc.untag self.uid, tag json = JSON.parse(response.body) if json['worked'] self..delete tag save! end end |
#update_from_dailycred(dc) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/dailycred/acts_as_dailycred.rb', line 58 def update_from_dailycred dc bad = ['updated_at', 'created_at'] dc.each do |k,v| self.send("#{k}=", v) if self.respond_to?(k) and !bad.include?(k.to_s) end save! end |