class

Artistry::Artifact

Inherits Reference < Object

Constructors

create(plugin : String, kind : String, data) : Artifact

Create via plugin and kind names

Source
create(kind_or_code : String, data) : Artifact

Create via code or kind name

Source
new(id : Int64, code : String, version : Int32, data : JSON::Any, hash : String, created_at : Int64, new_id : Int64 | Nil = nil, updated_at : Int64 | Nil = nil)
Source

Class methods

find(id : Int64) : Artifact | Nil

Find by ID

Source
find(slug : String) : Artifact | Nil

Find by slug (e.g., "E42", "EV123")

Source
hash_data(data_json : String) : String
Source
where(code : String, include_superseded : Bool = false) : Array(Artifact)

Query artifacts by code (current versions only by default)

Source
where(code : String, include_superseded : Bool = false, **conditions) : Array(Artifact)

Query with JSON field conditions (current versions only by default)

Source

Instance methods

[](key : String) : JSON::Any

Access data fields

Source
[]?(key : String) : JSON::Any | Nil
Source
code
Source
created_at
Source
current?

Is this the current (non-superseded) version?

Source
data
Source
delete

Delete artifact (hard delete)

Source
hash

Generates an UInt64 hash value for this object.

This method must have the property that a == b implies a.hash == b.hash.

The hash value is used along with == by the Hash class to determine if two objects reference the same hash key.

Subclasses must not override this method. Instead, they must define hash(hasher), though usually the macro def_hash can be used to generate this method.

Source
history

Get the full history chain (oldest first)

Source
latest

Get the latest version in this artifact's chain

Source
new_id
Source
slug

Slug representation (e.g., "E1", "EV42")

Source
successor

Get the artifact that superseded this one

Source
superseded?

Has this been superseded by a newer version?

Source
update(new_data) : Artifact

COW update - creates new version, supersedes this one

Source
update!(new_data) : Artifact

Mutable update - modifies in place, sets updated_at

Source
updated_at
Source
version
Source