class Vindi::Model
Base model to vindi resources.
Public Class Methods
first(limit = 1)
click to toggle source
@example First Customer
@customer = Vindi::Customer.first
@example First two customers
@customers = Vindi::Customer.first(2)
# File lib/vindi/models/model.rb, line 56 def first(limit = 1) records = order_by(:created_at, :asc).per_page(limit) return records[0] if limit == 1 records end
last(limit = 1)
click to toggle source
@example Last customer
@customer = Vindi::Customer.last
@example Last two customers
@customers = Vindi::Customer.last(2)
# File lib/vindi/models/model.rb, line 70 def last(limit = 1) records = order_by(:created_at, :desc).per_page(limit) return records[0] if limit == 1 records end
Public Instance Methods
archive!()
click to toggle source
Archive a record.
@example Archive a customer
Vindi::Customer.find_by(email: "sarumanthewhite@middlearth.io").archive!
# File lib/vindi/models/model.rb, line 40 def archive! destroy end
valid?()
click to toggle source
@private
Calls superclass method
# File lib/vindi/models/model.rb, line 45 def valid? super && response_errors.empty? end