Module: JasonObjectListProperties::MetaListProperties

Defined in:
lib/medea/list_properties.rb

Instance Method Summary collapse

Instance Method Details

#create_member_list(list_name, list_class, list_type) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/medea/list_properties.rb', line 7

def create_member_list list_name, list_class, list_type
  list = {}
  list = self.send(:class_variable_get, :@@lists) if self.class_variable_defined? :@@lists
  list[list_name] = [list_class, list_type]
  self.send(:class_variable_set, "@@lists", list)

  define_method(list_name) do
    #puts "Looking at the #{list_name.to_s} list, which is full of #{list_type.name}s"
    Medea::JasonListProperty.new self, list_name, list_class, list_type
  end
end

#has_many(list_name, list_class) ⇒ Object



19
20
21
# File 'lib/medea/list_properties.rb', line 19

def has_many list_name, list_class
  create_member_list list_name, list_class, :reference
end

#owns_many(list_name, list_class) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/medea/list_properties.rb', line 23

def owns_many list_name, list_class
  create_member_list list_name, list_class, :value

  #also modify the items in the list so that they know that they're owned
  #list_type.class_variable_set :@@owner, self
  list_class.owned = true
end