class Supertag::Moneytag
Constants
- MONEYTAG_REGEX
TODO Beef up the regex (ie.:what if content is HTML) this is how Twitter does it: github.com/twitter/twitter-text-rb/blob/master/lib/twitter-text/regex.rb
Public Class Methods
clean_orphans()
click to toggle source
# File lib/supertag/moneytag.rb, line 56 def self.clean_orphans # From DB # TODO Make this method call a single SQL query orphans = self.all.select { |h| h.moneytaggables.size == 0 } orphans.map(&:destroy) end
find_by_name(name)
click to toggle source
# File lib/supertag/moneytag.rb, line 14 def self.find_by_name(name) Moneytag.where("lower(name) =?", name.downcase).first end
find_or_create_by_name(name, &block)
click to toggle source
# File lib/supertag/moneytag.rb, line 18 def self.find_or_create_by_name(name, &block) find_by_name(name) || create(name: name, &block) end
Public Instance Methods
moneytaggables()
click to toggle source
# File lib/supertag/moneytag.rb, line 31 def moneytaggables self.moneytaggings.includes(:moneytaggable).collect { |h| h.moneytaggable } end
moneytagged_ids_by_types()
click to toggle source
# File lib/supertag/moneytag.rb, line 39 def moneytagged_ids_by_types moneytagged_ids ||= {} self.moneytaggings.each do |h| moneytagged_ids[h.moneytaggable_type] ||= Array.new moneytagged_ids[h.moneytaggable_type] << h.moneytaggable_id end moneytagged_ids end
moneytagged_ids_for_type(type)
click to toggle source
# File lib/supertag/moneytag.rb, line 48 def moneytagged_ids_for_type(type) moneytagged_ids_by_types[type] end
moneytagged_types()
click to toggle source
# File lib/supertag/moneytag.rb, line 35 def moneytagged_types self.moneytaggings.pluck(:moneytaggable_type).uniq end
name()
click to toggle source
# File lib/supertag/moneytag.rb, line 27 def name read_attribute(:name).downcase end
name=(val)
click to toggle source
# File lib/supertag/moneytag.rb, line 23 def name=(val) write_attribute(:name, val.downcase) end
to_s()
click to toggle source
# File lib/supertag/moneytag.rb, line 52 def to_s name end