module Redcord::Base
Public Class Methods
descendants()
click to toggle source
# File lib/redcord/base.rb, line 65 def self.descendants descendants = [] # TODO: Use T::Struct instead of Class ObjectSpace.each_object(Class) do |klass| descendants << klass if klass < self end descendants end
included(klass)
click to toggle source
# File lib/redcord/base.rb, line 34 def self.included(klass) # Redcord uses `T::Struct` to validate the attribute types. The # Redcord models need to inherit `T::Struct` and include # `Redcord::Base`, for example: # # class MyRedisModel < T::Struct # include Redcord::Base # # attribute :my_redis_value, Integer # end # # See more examples in spec/lib/redcord_spec.rb. klass.class_eval do # Redcord Model level methods include Redcord::Serializer include Redcord::Actions include Redcord::Attribute include Redcord::RedisConnection # Redcord stores the serialized model as a hash on Redis. When # reading a model from Redis, the hash fields are deserialized and # coerced to the specified attribute types. Like ActiveRecord, # Redcord manages the created_at and updated_at fields behind the # scene. prop :created_at, T.nilable(Time) prop :updated_at, T.nilable(Time) end end