Sha256: f9754f013840af4b5c814419e098ecbc843b6cd5909b16e3c0eba0c228a296bb
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# TODO support structured properties module Rails module MetaTags module ModelSupport autoload :Data, 'rails/meta_tags/model_support/data' autoload :DataConfig, 'rails/meta_tags/model_support/data_config' extend ActiveSupport::Concern # defaults specific to model support DEFAULTS = { :title => :to_s, :created => lambda { |r| r.updated_at.strftime('%Y-%m-%d') } }.freeze module ClassMethods def meta(&block) raise "no block given" unless block if ancestor = meta_ancestor @data = DataConfig.new(ancestor.to_hash) else @data = DataConfig.new(DEFAULTS.dup) end @data.configure_via_block(block) @data end def meta_ancestor ancestors.each do |ancestor| next if ancestor == ModelSupport || ancestor == self return ancestor.meta_config if ancestor.respond_to?(:meta_config) end nil end def meta_config @data || meta_ancestor end end def meta self.class.meta_config.instance(self) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_meta_tags-0.3.2 | lib/rails/meta_tags/model_support.rb |
rails_meta_tags-0.3.1 | lib/rails/meta_tags/model_support.rb |