Module: Applicat::Mvc::Model::Tokenable::ClassMethods
- Defined in:
- lib/applicat/mvc/model/tokenable.rb
Instance Method Summary collapse
Instance Method Details
#ids_from_tokens(tokens) ⇒ Object
19 20 21 22 |
# File 'lib/applicat/mvc/model/tokenable.rb', line 19 def ids_from_tokens(tokens) tokens.gsub!(/<<<(.+?)>>>/) { create!(name: $1).id } tokens.split(',') end |
#tokens(query) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/applicat/mvc/model/tokenable.rb', line 9 def tokens(query) collection = where("name like ?", "%#{query}%") if collection.empty? [{id: "<<<#{query}>>>", name: "#{I18n.t('general.new')}: \"#{query}\""}] else collection end end |