module SuchMeta::ControllerExtensions

Public Instance Methods

such_meta(tag_type, value = nil) click to toggle source
# File lib/such_meta/controller_extensions.rb, line 9
def such_meta(tag_type, value = nil)
  value ? set_meta_data(tag_type, value) : get_meta_data(tag_type)
end

Private Instance Methods

get_meta_data(tag_type) click to toggle source
# File lib/such_meta/controller_extensions.rb, line 23
def get_meta_data(tag_type)
  content = [
    # 1. Check the override hash
    OverrideHashFetcher.new(tag_type, such_meta_data),
    # 2. Check for specific I18n data
    SpecificI18nFetcher.new(tag_type, controller_name, action_name),
    # 3. Check for default I18n data
    DefaultI18nFetcher.new(tag_type, controller_name, action_name)
  ].detect(&:content?)

  # Return the content or raise an error
  content ? content.call : fail(MissingMetaDataError, "Missing meta data for key: #{tag_type}")
end
set_meta_data(tag_type, value) click to toggle source
# File lib/such_meta/controller_extensions.rb, line 19
def set_meta_data(tag_type, value)
  such_meta_data[tag_type.to_sym] = value
end
such_meta_data() click to toggle source
# File lib/such_meta/controller_extensions.rb, line 15
def such_meta_data
  @such_meta_data ||= {}
end