Module: ReadActivity::Reader::InstanceMethods
- Defined in:
- lib/read_activity/reader.rb
Instance Method Summary collapse
- #method_missing(method, *arguments, &block) ⇒ Object
-
#read!(readable) ⇒ Object
inverse of Readable#read_by!.
-
#read?(readable) ⇒ Boolean
inverse of Readable#read_by?.
-
#read_at(readable) ⇒ Object
inverse of Readable#read_by_at.
- #readables_marked_as_read(klass) ⇒ Object
- #readables_unmarked_as_read(klass) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/read_activity/reader.rb', line 48 def method_missing(method, *arguments, &block) if method.to_s =~ /^read_(.*)/ readables_marked_as_read($1.singularize.camelize.constantize, *arguments, &block) elsif method.to_s =~ /^unread_(.*)/ readables_unmarked_as_read($1.singularize.camelize.constantize, *arguments, &block) else super end end |
Instance Method Details
#read!(readable) ⇒ Object
inverse of Readable#read_by!
26 27 28 |
# File 'lib/read_activity/reader.rb', line 26 def read!(readable) readable.read_by!(self) end |
#read?(readable) ⇒ Boolean
inverse of Readable#read_by?
31 32 33 |
# File 'lib/read_activity/reader.rb', line 31 def read?(readable) readable.read_by?(self) end |
#read_at(readable) ⇒ Object
inverse of Readable#read_by_at
44 45 46 |
# File 'lib/read_activity/reader.rb', line 44 def read_at(readable) readable.read_by_at(self) end |
#readables_marked_as_read(klass) ⇒ Object
35 36 37 |
# File 'lib/read_activity/reader.rb', line 35 def readables_marked_as_read(klass) klass.send(:find_read_by, self) end |
#readables_unmarked_as_read(klass) ⇒ Object
39 40 41 |
# File 'lib/read_activity/reader.rb', line 39 def readables_unmarked_as_read(klass) klass.send(:find_unread_by, self) end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
58 59 60 61 62 63 64 65 |
# File 'lib/read_activity/reader.rb', line 58 def respond_to_missing?(method, include_private = false) method_name = method.to_s if method_name.start_with?("read_") or method_name.start_with?("unread_") true else super end end |