lib/markable/acts_as_markable.rb in markable-0.1.1 vs lib/markable/acts_as_markable.rb in markable-0.1.2

- old
+ new

@@ -68,9 +68,25 @@ Markable.add_markable self end end module MarkableInstanceMethods + + def method_missing(method_sym, *args) + Markable.models.each do |model_name| + if method_sym.to_s =~ Regexp.new("^#{model_name.downcase.pluralize}_have_marked_as(_[\\w_]+)?$") + model_name.constantize # ping model + + if self.methods.include? method_sym # method has appear + return self.method(method_sym).call(*args) # call this method + end + end + end + super + rescue + super + end + def mark_as(mark, markers) Array.wrap(markers).each do |marker| Markable.can_mark_or_raise? marker, self, mark params = { :markable_id => self.id,