class PUNK::Model

Public Class Methods

sample(count = 1) click to toggle source
# File lib/punk/framework/model.rb, line 36
def self.sample(count = 1)
  query = sample_dataset(count)
  count == 1 ? query.first : query.all
end
sample_dataset(count = 1) click to toggle source
# File lib/punk/framework/model.rb, line 32
def self.sample_dataset(count = 1)
  order(Sequel.lit("random()")).limit(count)
end
symbolize(*names) click to toggle source
Calls superclass method
# File lib/punk/framework/model.rb, line 41
def self.symbolize(*names)
  names.each do |name|
    chain =
      Module.new do
        define_method(name) do |*args|
          super(*args)&.to_sym
        end
      end
    prepend chain
  end
end

Public Instance Methods

inspect() click to toggle source
# File lib/punk/framework/model.rb, line 28
def inspect
  id.present? ? "#{id}|#{self}" : to_s
end
validate() click to toggle source
# File lib/punk/framework/model.rb, line 25
def validate
end