Module: Tito::Eventable::ClassMethods
- Defined in:
- lib/tito/eventable.rb
Instance Method Summary collapse
- #account_id_from_params(params) ⇒ Object
- #event_id_from_params(params) ⇒ Object
- #path(params = nil) ⇒ Object
Instance Method Details
#account_id_from_params(params) ⇒ Object
25 26 27 28 |
# File 'lib/tito/eventable.rb', line 25 def account_id_from_params(params) return params[:event][:account_id] if params[:event] return params[:filter][:account_id] if params[:filter] end |
#event_id_from_params(params) ⇒ Object
20 21 22 23 |
# File 'lib/tito/eventable.rb', line 20 def event_id_from_params(params) return params[:event][:id] if params[:event] return params[:filter][:event_id] if params[:filter] end |
#path(params = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tito/eventable.rb', line 30 def path(params=nil) prefix_path = '%{account_id}/%{event_id}' path_params = params.delete(:path) || params path_params[:event_id] = event_id_from_params(params) path_params[:account_id] = account_id_from_params(params) parts = [].unshift(prefix_path % path_params.symbolize_keys) parts << table_name File.join(*parts) rescue KeyError raise ArgumentError, "Please make sure to include account_id and event_id" end |