Module: Zenbox::UserHelper

Defined in:
lib/zenbox/user_helper.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/zenbox/user_helper.rb', line 3

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#zenbox_data(*fields) ⇒ Object



15
16
17
18
19
# File 'lib/zenbox/user_helper.rb', line 15

def zenbox_data(*fields)
  fields = fields.empty? ? self.class.class_variable_get('@@zenbox_fields') : fields

  fields.inject({}) { |run, field| run[field] = self.send(field.to_sym); run }
end

#zenbox_sync!Object

TODO: Catch errors because of missing methods and prompt the user, “Tried to sync a non-existant method with zenbox. Please make sure to implement #method_name on your model”



11
12
13
# File 'lib/zenbox/user_helper.rb', line 11

def zenbox_sync!
  Zenbox.post(self.email, zenbox_data)
end