Module: Izzle::HasEasy::AssocationExtension

Defined in:
lib/has_easy/association_extension.rb

Instance Method Summary collapse

Instance Method Details

#[](name) ⇒ Object



17
18
19
# File 'lib/has_easy/association_extension.rb', line 17

def [](name)
  proxy_association.owner.get_has_easy_thing(proxy_association.reflection.name, name)
end

#[]=(name, value) ⇒ Object



13
14
15
# File 'lib/has_easy/association_extension.rb', line 13

def []=(name, value)
  proxy_association.owner.set_has_easy_thing(proxy_association.reflection.name, name, value)
end

#saveObject



5
6
7
# File 'lib/has_easy/association_extension.rb', line 5

def save
  do_save(false)
end

#save!Object



9
10
11
# File 'lib/has_easy/association_extension.rb', line 9

def save!
  do_save(true)
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/has_easy/association_extension.rb', line 21

def valid?
  valid = true
  proxy_association.target.each do |thing|
    thing.model_cache = proxy_association.owner
    unless thing.valid?
      thing.errors.each{ |attr, msg| proxy_association.owner.errors.add(proxy_association.reflection.name, msg) }
      valid = false
    end
  end
  valid
end