Module: Redis::Relations

Included in:
ORM
Defined in:
lib/redis/relations.rb

Defined Under Namespace

Modules: BelongsTo, HasMany, HasOne

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/redis/relations.rb', line 6

def self.included(base)
  base.class_eval do
    class << self
      def add_relation(name)
        varn = "#{name}_relations"
        class_inheritable_hash varn                       # class_inheritable_hash 'belongs_to_relations'
        send(varn) || send("#{varn}=", {})                # self.belongs_to_relations ||= {}
        within_save_block "save_#{name}_references"       # within_save_block 'save_belongs_to_references'
      end
    end
    
    include Redis::Relations::BelongsTo
    include Redis::Relations::HasMany
    include Redis::Relations::HasOne
  end
end