Module: Acts::Container::InstanceMethods
- Defined in:
- lib/acts/container.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/acts/container.rb', line 34 def self.included(base) # :nodoc: base.extend ClassMethods end |
Instance Method Details
#<<(content) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/acts/container.rb', line 46 def <<(content) content.container = nil self.containables.each do |containable| begin self.send(containable).<< content return # if it successfully adds we are done with this method. # there is probably a better way to do this. right now if it can't be added to the container # we just catch that exception and keep going until we iterate through all the possibilities rescue ActiveRecord::AssociationTypeMismatch next end end raise Exception.new("Unable to add content to container. Object type did not match any containable type.") end |
#contents ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/acts/container.rb', line 38 def contents contents = [] self.containables.each do |containable| contents += self.send(containable) end contents end |
#message(message_string) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/acts/container.rb', line 62 def () self.handle.() if self.respond_to?(:handle) self.contents.each do |content| content.() end end |