Module: Tripod::Embeds
- Extended by:
- ActiveSupport::Concern
- Included in:
- Components
- Defined in:
- lib/tripod/embeds.rb,
lib/tripod/embeds/many.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Many
Instance Method Summary
collapse
Instance Method Details
#embedded_are_valid ⇒ Object
14
15
16
17
18
|
# File 'lib/tripod/embeds.rb', line 14
def embedded_are_valid
self.class.get_embedded.each do |name|
self.errors.add(name, 'contains an invalid resource') unless self.send(name).all? {|resource| resource.valid? }
end
end
|
#get_embeds(name, predicate, opts) ⇒ Object
8
9
10
11
12
|
# File 'lib/tripod/embeds.rb', line 8
def get_embeds(name, predicate, opts)
klass = opts.fetch(:class, nil)
klass ||= (self.class.name.deconstantize + '::' + name.to_s.classify).constantize
Many.new(klass, predicate, self)
end
|