Module: GritterNotices::ActiveRecord::InstanceMethods
- Defined in:
- lib/gritter_notices/active_record.rb
Instance Method Summary collapse
-
#gritter_notice(*args) ⇒ Object
(also: #notice)
Examples:.
-
#method_missing(method_name, *args, &block) ⇒ Object
notice_success notice_error notice_warning notice_progress notice_notice - default.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
notice_success notice_error notice_warning notice_progress notice_notice - default. An alias for ‘notice`
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gritter_notices/active_record.rb', line 41 def method_missing(method_name, *args, &block) if level = ValidMethods[method_name.to_s] or level = ValidMethods["gritter_#{method_name}"] = args. [:level] = level args << gritter_notice *args else super(method_name, *args, &block) end end |
Instance Method Details
#gritter_notice(*args) ⇒ Object Also known as: notice
Examples:
notice :text=>‘asdsad’, :image=>:notice notice ‘message’, :level=>:success
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gritter_notices/active_record.rb', line 19 def gritter_notice *args = args. text = args.first || [:text] = {:scope=>:gritter_notices}.merge if text.is_a? Symbol [:gritter_key] = text [:level] = text unless [:level] text = [:text] || I18n::translate(text, ) end [:level]=:notice unless [:level] gritter_notices.create! :text=>text, :options=> end |