class Polytag::Concerns::Taggable::ModelHelpers
Public Class Methods
new(owner)
click to toggle source
# File lib/polytag/concerns/taggable/model_helpers.rb, line 5 def initialize(owner) @owner = owner end
Public Instance Methods
del(tag, args = {})
click to toggle source
# File lib/polytag/concerns/taggable/model_helpers.rb, line 19 def del(tag, args = {}) return false unless exist?(tag, args) tag = ::Polytag.get tag: tag, tag_group: args[:tag_group], owner: args[:tag_group_owner], tagged: @owner, foc: :first tag.destroy true end
exist?(tag, args = {})
click to toggle source
# File lib/polytag/concerns/taggable/model_helpers.rb, line 44 def exist?(tag, args = {}) tag = ::Polytag.get tag: tag, tag_group: args[:tag_group], owner: args[:tag_group_owner], tagged: @owner, foc: :first # Return the result tag.is_a?(::Polytag::Connection) rescue ActiveRecord::RecordNotFound false end
Also aliased as: has_tag?
get(tag, args = {})
click to toggle source
# File lib/polytag/concerns/taggable/model_helpers.rb, line 34 def get(tag, args = {}) return false unless exist?(tag, args) ::Polytag.get tag: tag, tag_group: args[:tag_group], owner: args[:tag_group_owner], tagged: @owner, foc: :first end
Also aliased as: find
new(tag, args = {})
click to toggle source
# File lib/polytag/concerns/taggable/model_helpers.rb, line 9 def new(tag, args = {}) ::Polytag.get tag: tag, foc: :first_or_create, tag_group: args[:tag_group], owner: args[:tag_group_owner], tagged: @owner end