module Redcord::Actions::InstanceMethods
Public Instance Methods
_set_args!(args)
click to toggle source
# File lib/redcord/actions.rb, line 246 def _set_args!(args) args.each do |key, value| send(:"#{key}=", value) end end
created_at()
click to toggle source
# File lib/redcord/actions.rb, line 118 def created_at; end
created_at=(time)
click to toggle source
# File lib/redcord/actions.rb, line 125 def created_at=(time); end
destroy()
click to toggle source
# File lib/redcord/actions.rb, line 229 def destroy Redcord::Base.trace( 'redcord_actions_instance_methods_destroy', model_name: self.class.name, ) do return false if id.nil? self.class.destroy(T.must(id)) end end
id()
click to toggle source
# File lib/redcord/actions.rb, line 253 def id instance_variable_get(:@_id) end
instance_key()
click to toggle source
# File lib/redcord/actions.rb, line 241 def instance_key "#{self.class.model_key}:id:#{T.must(id)}" end
save()
click to toggle source
# File lib/redcord/actions.rb, line 177 def save save! true rescue Redis::CommandError # TODO: break down Redis::CommandError by parsing the error message false end
save!()
click to toggle source
# File lib/redcord/actions.rb, line 138 def save! Redcord::Base.trace( 'redcord_actions_instance_methods_save!', model_name: self.class.name, ) do self.updated_at = Time.zone.now _id = id if _id.nil? serialized_instance = serialize self.class.props.keys.each do |attr_key| serialized_instance[attr_key.to_s] = nil unless serialized_instance.key?(attr_key.to_s) end self.created_at = T.must(self.updated_at) _id = redis.create_hash_returning_id( self.class.model_key, self.class.to_redis_hash(serialized_instance), ttl: self.class._script_arg_ttl, index_attrs: self.class._script_arg_index_attrs, range_index_attrs: self.class._script_arg_range_index_attrs, custom_index_attrs: self.class._script_arg_custom_index_attrs, hash_tag: hash_tag, ) send(:id=, _id) else redis.update_hash( self.class.model_key, _id, self.class.to_redis_hash(serialize), ttl: self.class._script_arg_ttl, index_attrs: self.class._script_arg_index_attrs, range_index_attrs: self.class._script_arg_range_index_attrs, custom_index_attrs: self.class._script_arg_custom_index_attrs, hash_tag: hash_tag, ) end end end
update(args)
click to toggle source
# File lib/redcord/actions.rb, line 219 def update(args) update!(args) true rescue Redis::CommandError # TODO: break down Redis::CommandError by parsing the error message false end
update!(args)
click to toggle source
# File lib/redcord/actions.rb, line 187 def update!(args) Redcord::Base.trace( 'redcord_actions_instance_methods_update!', model_name: self.class.name, ) do shard_by_attr = self.class.shard_by_attribute if args.keys.include?(shard_by_attr) raise Redcord::InvalidAction, "Cannot update shard_by attribute #{shard_by_attr}" end _id = id if _id.nil? _set_args!(args) save! else args[:updated_at] = Time.zone.now _set_args!(args) redis.update_hash( self.class.model_key, _id, self.class.to_redis_hash(args), ttl: self.class._script_arg_ttl, index_attrs: self.class._script_arg_index_attrs, range_index_attrs: self.class._script_arg_range_index_attrs, custom_index_attrs: self.class._script_arg_custom_index_attrs, hash_tag: hash_tag, ) end end end
updated_at()
click to toggle source
# File lib/redcord/actions.rb, line 128 def updated_at; end
updated_at=(time)
click to toggle source
# File lib/redcord/actions.rb, line 135 def updated_at=(time); end
Private Instance Methods
id=(id)
click to toggle source
# File lib/redcord/actions.rb, line 260 def id=(id) instance_variable_set(:@_id, id) end