abstract class Avram::Box

Defined in:

avram/box.cr

Constant Summary

SEQUENCES = {} of String => Int32

Class Method Summary

Instance Method Summary

Macro Summary

Instance methods inherited from class Object

blank_for_validates_required? : Bool blank_for_validates_required?

Class Method Detail

def self.create #

[View source]
def self.create(&) #

[View source]
def self.create_pair #

Returns an array with 2 instances of the model from the Box.

Usage:

tags = TagBox.create_pair
typeof(tags) # => Array(Tag)
tags.size    # => 2

[View source]
def self.create_pair(&) #

Similar to .create_pair, but accepts a block which yields the box instance.

Both boxes receive the same argument values.

Usage:

TagBox.create_pair do |box|
  # set both boxes name to "test"
  box.name("test")
end

[View source]
def self.save #

[View source]

Instance Method Detail

def create #

[View source]
def operation #

[View source]
def sequence(value : String) : String #

Returns a value with a number to use for unique values.

Usage:

class UserBox < Avram::Box
  def initialize
    username sequence("username")            # => username-1, username-2, etc.
    email "#{sequence("email")}@example.com" # => [email protected], [email protected], etc.
  end
end

[View source]

Macro Detail

macro setup_attribute_shortcuts(operation) #

[View source]