module Gamifier::Model::ClassMethods

Public Instance Methods

container() click to toggle source

Returns the container to use when submitting data. E.g. when submitting user attributes as user=xxx, the container is ‘user’. Basically, this is the underscored class name.

# File lib/gamifier/model.rb, line 200
def container
  Gamifier.underscore(name)
end
mutable_attributes(*values) click to toggle source

Define the attributes that will be sent when creating or updating a model.

# File lib/gamifier/model.rb, line 185
def mutable_attributes *values
  store_or_get("@mutable_attributes", values)
end
path(value = nil) click to toggle source

Sets or retrieve the path to use to access the resource on the remote server. By default the path will be the pluralized container name (naive pluralization: container+s).

# File lib/gamifier/model.rb, line 169
def path(value = nil)
  if value.nil?
    @path ||= container+"s"
  else
    @path = value
  end
end
reset!() click to toggle source
# File lib/gamifier/model.rb, line 162
def reset!
  @path = nil
end
special_attributes(*values) click to toggle source

Declare attributes that must be submitted outside the default container.

# File lib/gamifier/model.rb, line 179
def special_attributes *values
  store_or_get("@special_attributes", values)
end
store_or_get(variable, values) click to toggle source
# File lib/gamifier/model.rb, line 189
def store_or_get(variable, values)
  if values.empty?
    v = instance_variable_get(variable)
    v ||= []
  else
    instance_variable_set(variable, values.map{|v| v.to_sym})
  end
end