class Phaseout::SEOAction
Attributes
action[R]
controller[R]
Public Class Methods
all() { |self( match(/#{ redis.namespace }\:action\:/).post_match )| ... }
click to toggle source
# File lib/phaseout/seo_action.rb, line 55 def self.all(&block) unless block_given? values = [] self.all{ |action| values << action } return values end pattern = "#{Phaseout.redis.namespace}:action:*" Phaseout.redis.scan_each(match: pattern) do |value| yield self.new( value.match(/#{ Phaseout.redis.namespace }\:action\:/).post_match ) end end
find(key)
click to toggle source
# File lib/phaseout/seo_action.rb, line 51 def self.find(key) self.new "action:#{key}" end
new(controller_or_key, action = nil)
click to toggle source
# File lib/phaseout/seo_action.rb, line 5 def initialize(controller_or_key, action = nil) if action @controller, @action = controller_or_key, action else @controller, @action = controller_or_key.split '#' end end
Public Instance Methods
add(field_key)
click to toggle source
# File lib/phaseout/seo_action.rb, line 33 def add(field_key) Phaseout.redis.sadd key, field_key end
fields(&block)
click to toggle source
# File lib/phaseout/seo_action.rb, line 21 def fields(&block) if block_given? SEOFields.all self.key, &block else @fields ||= SEOFields.all self.key end end
id()
click to toggle source
# File lib/phaseout/seo_action.rb, line 17 def id I18n.transliterate([ @controller, @action ].join '-' ).gsub(/\s+/, '_').underscore end
key()
click to toggle source
# File lib/phaseout/seo_action.rb, line 13 def key I18n.transliterate([ @controller, @action ].join '#' ).gsub(/\s+/, '_').underscore end
name()
click to toggle source
# File lib/phaseout/seo_action.rb, line 29 def name controller.camelize.constantize.seo_group_name[key] || key end
remove(field_key)
click to toggle source
# File lib/phaseout/seo_action.rb, line 37 def remove(field_key) Phaseout.redis.srem key, field_key end
to_json()
click to toggle source
# File lib/phaseout/seo_action.rb, line 41 def to_json { id: id, key: key, name: name, action: action, controller: controller }.to_json end