class

PlaceOS::Model::Upload

Inherits PlaceOS::Model::Timestamps < PlaceOS::Model::ModelBase < PlaceOS::Model::Associations < Neuroplastic < PgORM::Base < PgORM::Validators < PgORM::Table < PgORM::Persistence < PgORM::Associations < ActiveModel::Callbacks < ActiveModel::Validation < ActiveModel::Model < DB::Mappable < DB::Serializable < YAML::Serializable < JSON::Serializable < Reference < Object

Constants

CALLBACKS = { before_save: [] of Nil, after_save: [] of Nil, before_create: [do self.created_at = self.updated_at = Time.utc end] of Nil, after_create: [] of Nil, before_update: [do self.updated_at = Time.utc end] of Nil, after_update: [] of Nil, before_destroy: [:delete_data, :remove_from_pending_mail] of Nil, after_destroy: [] of Nil, }
Log = ::Log.for(self)
PRIMARY_KEY_TYPES = {:id => (String | Nil)} of Nil => Nil

macro level key => type

PRIMARY_KEYS = [{:id}]

Constructors

from_json(string_or_io : String | IO, trusted : Bool = false) : self
from_json(string_or_io : String | IO, root : String, trusted : Bool = false) : self

Deserializes the given JSON in string_or_io into an instance of self, assuming the JSON consists of an JSON object with key root, and whose value is the value to deserialize. Will not deserialise from fields with mass_assign: false

class User < ActiveModel::Model
  attribute name : String
  attribute google_id : UUID, mass_assign: false
end

User.from_json(%({"main": {"name": "Jason", "google_id": "f6f70bfb-c882-446d-8758-7ce47db39620"}}), root: "main") # => #<User:0x103131b20 @name="Jason">
from_trusted_json(string_or_io : String | IO, root : String) : self
from_trusted_json(string_or_io : String | IO) : self

Serialize from a trusted JSON source

from_trusted_yaml(string_or_io : String | IO) : self

Serialize from a trusted YAML source

from_yaml(string_or_io : String | IO, trusted : Bool = false) : self
new(rs : DB::ResultSet)
new(created_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new, updated_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new, uploaded_email : PlaceOS::Model::Email | ActiveModel::Model::None = ::ActiveModel::Model::None.new, file_name : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, file_size : Int64 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, file_path : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, object_key : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, file_md5 : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, cache_etag : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, cache_modified : Time | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, public : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, permissions : PlaceOS::Model::Upload::Permissions | ActiveModel::Model::None = ::ActiveModel::Model::None.new, object_options : Hash(String, JSON::Any) | ActiveModel::Model::None = ::ActiveModel::Model::None.new, resumable_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, resumable : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, part_list : Array(Int32) | ActiveModel::Model::None = ::ActiveModel::Model::None.new, part_data : Hash(String, JSON::Any) | ActiveModel::Model::None = ::ActiveModel::Model::None.new, upload_complete : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, tags : Array(String) | ActiveModel::Model::None = ::ActiveModel::Model::None.new, storage_id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, uploaded_by : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, id : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new)

Initialize PlaceOS::Model::Upload from HTTP::Params.

Class methods

attributes

Returns all attribute keys.

by_storage_id(id)

Look up instances of this model dependent on the foreign key

Source
by_uploaded_by(id)

Look up instances of this model dependent on the foreign key

Source
changes(id : String | Nil | Nil = nil) : ChangeFeed

Changefeed at row (if id passed) or whole table level. Returns a ChangeFeed instance which can be used to invoke async callbacks via on or use blocking Iterator via each method.

elastic
from_rs(__temp_1966 : DB::ResultSet)
on_error(err : Exception | IO::Error)
primary_key

Base class for all Engine models

Source
safe_filename?(filename : String) : Bool
Source
table_name

Instance methods

__storage
__storage=(__storage : Storage | Nil)
__user
__user=(__user : User | Nil)
after_create

Base class for all Engine models

after_destroy

Base class for all Engine models

after_initialize(trusted : Bool)
after_save

Base class for all Engine models

after_update

Base class for all Engine models

apply_defaults

Generate code to apply default values

assign_attributes(created_at : Time | Missing = Missing, updated_at : Time | Missing = Missing, uploaded_email : PlaceOS::Model::Email | Missing = Missing, file_name : String | Missing = Missing, file_size : Int64 | Missing = Missing, file_path : String | Nil | Missing = Missing, object_key : String | Missing = Missing, file_md5 : String | Missing = Missing, cache_etag : String | Nil | Missing = Missing, cache_modified : Time | Nil | Missing = Missing, public : Bool | Missing = Missing, permissions : PlaceOS::Model::Upload::Permissions | Missing = Missing, object_options : Hash(String, JSON::Any) | Missing = Missing, resumable_id : String | Nil | Missing = Missing, resumable : Bool | Missing = Missing, part_list : Array(Int32) | Missing = Missing, part_data : Hash(String, JSON::Any) | Missing = Missing, upload_complete : Bool | Missing = Missing, tags : Array(String) | Missing = Missing, storage_id : String | Nil | Missing = Missing, uploaded_by : String | Nil | Missing = Missing, id : String | Nil | Missing = Missing)

Assign to multiple attributes.

assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))

Assign to multiple attributes via HTTP::Params.

assign_attributes(model : PlaceOS::Model::Upload)

Assign to multiple attributes from a model object

assign_attributes_from_json(json, root : String)
assign_attributes_from_json(json)
assign_attributes_from_trusted_json(json, root : String)
assign_attributes_from_trusted_json(json)

Assign each field from JSON if field exists in JSON and has changed in model

assign_attributes_from_trusted_yaml(yaml)
assign_attributes_from_yaml(yaml)

Uses the YAML parser as JSON is valid YAML

attributes

Returns a Hash of all attribute values

attributes_tuple

Returns a NamedTuple of all attribute values.

before_create

Base class for all Engine models

before_destroy

Base class for all Engine models

before_save

Base class for all Engine models

before_update

Base class for all Engine models

cache_etag

cache_etag getter

cache_etag=(value : String | Nil)

cache_etag setter

cache_etag_assigned?
cache_etag_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

cache_etag_changed?
cache_etag_default

cache_etag's default value

Source
cache_etag_present?
cache_etag_removed?
cache_etag_was
cache_etag_will_change!

Include cache_etag in the set of changed attributes, whether it has changed or not.

cache_modified

cache_modified getter

cache_modified=(value : Time | Nil)

cache_modified setter

cache_modified_assigned?
cache_modified_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

cache_modified_changed?
cache_modified_default

cache_modified's default value

Source
cache_modified_present?
cache_modified_removed?
cache_modified_was
cache_modified_will_change!

Include cache_modified in the set of changed attributes, whether it has changed or not.

changed?

Check if any attributes have changed.

changed_attributes

Returns a Hash with all changed attributes.

changed_json(io : IO) : Nil

Serialize the set of changed attributes to JSON.

changed_json

Serialize the set of changed attributes to JSON.

changed_persist_attributes
changed_yaml(io : IO) : Nil

Serialize the set of changed attributes to YAML.

changed_yaml

Serialize the set of changed attributes to YAML.

clear_changes_information

Reset changes for all attributes.

created_at

created_at getter

created_at=(value : Time)

Setters created_at setter

created_at?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

created_at_assigned?
created_at_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

created_at_changed?
created_at_default

created_at's default value

created_at_present?
created_at_removed?
created_at_was
created_at_will_change!

Include created_at in the set of changed attributes, whether it has changed or not.

file_md5

file_md5 getter

file_md5=(value : String)

file_md5 setter

file_md5?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

file_md5_assigned?
file_md5_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

file_md5_changed?
file_md5_default

file_md5's default value

Source
file_md5_present?
file_md5_removed?
file_md5_was
file_md5_will_change!

Include file_md5 in the set of changed attributes, whether it has changed or not.

file_name

file_name getter

file_name=(value : String)

file_name setter

file_name?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

file_name_assigned?
file_name_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

file_name_changed?
file_name_default

file_name's default value

Source
file_name_present?
file_name_removed?
file_name_was
file_name_will_change!

Include file_name in the set of changed attributes, whether it has changed or not.

file_path

file_path getter

file_path=(value : String | Nil)

file_path setter

file_path_assigned?
file_path_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

file_path_changed?
file_path_default

file_path's default value

Source
file_path_present?
file_path_removed?
file_path_was
file_path_will_change!

Include file_path in the set of changed attributes, whether it has changed or not.

file_size

file_size getter

file_size=(value : Int64)

file_size setter

file_size?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

file_size_assigned?
file_size_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

file_size_changed?
file_size_default

file_size's default value

Source
file_size_present?
file_size_removed?
file_size_was
file_size_will_change!

Include file_size in the set of changed attributes, whether it has changed or not.

id

id getter

id=(value : String | Nil)

id setter

id?
id_assigned?
id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

id_changed?
id_default

id's default value

id_present?
id_removed?
id_was
id_will_change!

Include id in the set of changed attributes, whether it has changed or not.

invoke_props

Base class for all Engine models

object_key

object_key getter

object_key=(value : String)

object_key setter

object_key?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

object_key_assigned?
object_key_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

object_key_changed?
object_key_default

object_key's default value

Source
object_key_present?
object_key_removed?
object_key_was
object_key_will_change!

Include object_key in the set of changed attributes, whether it has changed or not.

object_options

object_options getter

object_options=(value : Hash(String, JSON::Any))

object_options setter

object_options?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

object_options_assigned?
object_options_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

object_options_changed?
object_options_default

object_options's default value

Source
object_options_present?
object_options_removed?
object_options_was
object_options_will_change!

Include object_options in the set of changed attributes, whether it has changed or not.

part_data

part_data getter

part_data=(value : Hash(String, JSON::Any))

part_data setter

part_data?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

part_data_assigned?
part_data_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

part_data_changed(flag : Bool = true)
Source
part_data_changed?
part_data_default

part_data's default value

Source
part_data_present?
part_data_removed?
part_data_was
part_data_will_change!

Include part_data in the set of changed attributes, whether it has changed or not.

part_list

part_list getter

part_list=(value : Array(Int32))

part_list setter

part_list?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

part_list_assigned?
part_list_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

part_list_changed?
part_list_default

part_list's default value

Source
part_list_present?
part_list_removed?
part_list_was
part_list_will_change!

Include part_list in the set of changed attributes, whether it has changed or not.

permissions

permissions getter

permissions setter

permissions?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

permissions_assigned?
permissions_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

permissions_changed?
permissions_default

permissions's default value

Source
permissions_present?
permissions_removed?
permissions_was
permissions_will_change!

Include permissions in the set of changed attributes, whether it has changed or not.

persistent_attributes

Returns a Hash of all attributes that can be persisted.

primary_key

Base class for all Engine models

Source
primary_key_hash
public

public getter

public=(value : Bool)

public setter

public?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

public_assigned?
public_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

public_changed?
public_default

public's default value

Source
public_present?
public_removed?
public_was
public_will_change!

Include public in the set of changed attributes, whether it has changed or not.

reset_associations
Source
restore_attributes

Reset each attribute to their previous values and clears all changes.

resumable

resumable getter

resumable=(value : Bool)

resumable setter

resumable?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

resumable_assigned?
resumable_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

resumable_changed?
resumable_default

resumable's default value

Source
resumable_id

resumable_id getter

resumable_id=(value : String | Nil)

resumable_id setter

resumable_id_assigned?
resumable_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

resumable_id_changed?
resumable_id_default

resumable_id's default value

Source
resumable_id_present?
resumable_id_removed?
resumable_id_was
resumable_id_will_change!

Include resumable_id in the set of changed attributes, whether it has changed or not.

resumable_present?
resumable_removed?
resumable_was
resumable_will_change!

Include resumable in the set of changed attributes, whether it has changed or not.

storage

Retrieves the parent relationship

Source
storage!
Source
storage=(parent : Storage)

Sets the parent relationship

Source
storage_id

storage_id getter

storage_id=(value : String | Nil)

storage_id setter

storage_id_assigned?
storage_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

storage_id_changed?
storage_id_default

storage_id's default value

storage_id_present?
storage_id_removed?
storage_id_was
storage_id_will_change!

Include storage_id in the set of changed attributes, whether it has changed or not.

table_name
tags

tags getter

tags=(value : Array(String))

tags setter

tags?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

tags_assigned?
tags_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

tags_changed?
tags_default

tags's default value

Source
tags_present?

so we can tag which system the upload belongs to allowing us to filter for relevancy

tags_removed?
tags_was
tags_will_change!

Include tags in the set of changed attributes, whether it has changed or not.

updated_at

updated_at getter

updated_at=(value : Time)

updated_at setter

updated_at?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

updated_at_assigned?
updated_at_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

updated_at_changed?
updated_at_default

updated_at's default value

updated_at_present?
updated_at_removed?
updated_at_was
updated_at_will_change!

Include updated_at in the set of changed attributes, whether it has changed or not.

upload_complete

upload_complete getter

upload_complete=(value : Bool)

upload_complete setter

upload_complete?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

upload_complete_assigned?
upload_complete_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

upload_complete_changed?
upload_complete_default

upload_complete's default value

Source
upload_complete_present?
upload_complete_removed?
upload_complete_was
upload_complete_will_change!

Include upload_complete in the set of changed attributes, whether it has changed or not.

uploaded_by

uploaded_by getter

uploaded_by=(value : String | Nil)

uploaded_by setter

uploaded_by_assigned?
uploaded_by_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

uploaded_by_changed?
uploaded_by_default

uploaded_by's default value

uploaded_by_present?
uploaded_by_removed?
uploaded_by_was
uploaded_by_will_change!

Include uploaded_by in the set of changed attributes, whether it has changed or not.

uploaded_email

uploaded_email getter

uploaded_email=(value : PlaceOS::Model::Email)

uploaded_email setter

uploaded_email?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

uploaded_email_assigned?
uploaded_email_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

uploaded_email_changed?
uploaded_email_default

uploaded_email's default value

Source
uploaded_email_present?
uploaded_email_removed?
uploaded_email_was
uploaded_email_will_change!

Include uploaded_email in the set of changed attributes, whether it has changed or not.

user

Retrieves the parent relationship

Source
user!
Source
user=(parent : User)

Sets the parent relationship

Source
validate_nilability

Validate that all non-nillable fields have values.

Nested types