class Nuvemshop::BaseModel
Public Class Methods
attr_accessor(*vars)
click to toggle source
Intercepts attr_acessor call, and assign it value to a variable named @attributes
Calls superclass method
# File lib/nuvemshop/base_model.rb, line 7 def self.attr_accessor(*vars) @attributes ||= [] @attributes.concat vars super(*vars) end
attributes()
click to toggle source
Getter to expose @attributes to class object
# File lib/nuvemshop/base_model.rb, line 15 def self.attributes @attributes end
Public Instance Methods
attributes()
click to toggle source
Getter to expose @attributes to class instance
# File lib/nuvemshop/base_model.rb, line 21 def attributes self.class.attributes end
pretty_print(pp)
click to toggle source
Overwrite default Ruby pretty_print
(q) method to act as ActiveRecord's output
# File lib/nuvemshop/base_model.rb, line 27 def pretty_print(pp) pp.object_address_group(self) do variables = self.class.attributes.map do |attribute| attribute.to_s.delete(':') end pp.seplist(variables, proc { pp.text ',' }) do |attr_name| pp.breakable ' ' pp.group(1) do pp.text attr_name pp.text ':' pp.breakable value = send(attr_name.to_sym) || nil pp.pp value end end end end