class Tango::AbstractModel
Base model for Tango
resources
@author Mckomo
Public Class Methods
next_id()
click to toggle source
Return incremented value of last id in the model's table
@return [Integer]
# File lib/tango/abstract_model.rb, line 38 def self.next_id @last_id ||= self.pluck( :id ).last || 0 @last_id += 1 end
persistent?()
click to toggle source
State wether model should be cached or not
@note If model is not persistent, model's table will be truncated @return [Boolean]
# File lib/tango/abstract_model.rb, line 47 def self.persistent? raise NotImplementedError end
properties()
click to toggle source
Return array with names of model properties
@return [Array]
# File lib/tango/abstract_model.rb, line 31 def self.properties @properties || @properties = self.attribute_names.map { |a| a.to_sym } end
Public Instance Methods
cache_key()
click to toggle source
Return cache key of model instance
@return [Object]
# File lib/tango/abstract_model.rb, line 24 def cache_key raise NotImplementedError end
values()
click to toggle source
Return array with values of model properties
@return [Array]
# File lib/tango/abstract_model.rb, line 17 def values self.attributes.values end