Sha256: 08db15bfb9d69463b828b569ed9318a8783d61cf4c10eef72bf3f9bce1e8c74f
Contents?: true
Size: 961 Bytes
Versions: 2
Compression:
Stored size: 961 Bytes
Contents
module Crystal class OptionsForController attr_reader :controller def initialize(controller) @controller = controller end def options paths.inject(default_options){|memo, path| memo.deep_merge!(I18n.t(path, :scope => scope, :default => {}))} end private def paths %W{ _defaults #{controller_path}._defaults #{controller_path}.#{alias_action} #{controller_path}.#{action} }.uniq end def scope 'meta' end def default_options HashWithStringifyKeys.new( :'og:url' => url ) end def url controller.request.url end def controller_path @controller_path ||= controller.controller_path.gsub(%r{/}, '.') end def action controller.action_name end def alias_action aliases[action] || action end def aliases {'update' => 'edit', 'create' => 'new'} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
crystalmeta-1.0.0 | lib/crystal/options_for_controller.rb |
crystalmeta-0.9.4 | lib/crystal/options_for_controller.rb |