Sha256: 0f4fa879476ef618d8ba53094f1a2eff301cd57f3c963f1846a17cde024dc8e8

Contents?: true

Size: 850 Bytes

Versions: 3

Compression:

Stored size: 850 Bytes

Contents

module Panoramic
  module Orm
    module ActiveRecord
      def store_templates
        class_eval do
          validates :body,    :presence => true
          validates :path,    :presence => true
          validates :format,  :inclusion => Mime::SET.symbols.map(&:to_s)
          validates :locale,  :inclusion => I18n.available_locales.map(&:to_s)
          validates :handler, :inclusion => ActionView::Template::Handlers.extensions.map(&:to_s)

          after_save { Panoramic::Resolver.instance.clear_cache }

          extend ClassMethods
        end
      end

      module ClassMethods
        def find_model_templates(conditions = {})
          self.where(conditions)
        end

        def resolver
          Panoramic::Resolver.using self
        end
      end
    end
  end
end

ActiveRecord::Base.extend Panoramic::Orm::ActiveRecord

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
panoramic-0.0.4 lib/panoramic/orm/active_record.rb
panoramic-0.0.3 lib/panoramic/orm/active_record.rb
panoramic-0.0.2 lib/panoramic/orm/active_record.rb