Sha256: c12a11edd52b0614fedf544f2a91989b7e50038971d445aea10d393bea0645a9

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

module Puffer
  module Controller
    module Mutate

      def self.included base
        base.class_eval do
          extend ClassMethods
          include InstanceMethods

          layout 'puffer'
          helper :puffer
          helper_method :puffer?, :namespace
        end
      end

      module InstanceMethods

        def puffer?
          self.class.puffer?
        end

        def namespace
          self.class.namespace
        end

      end

      module ClassMethods

        def puffer?
          true
        end

        def namespace
          to_s.underscore.split('/').first
        end

        def model_name
          @model_name ||= (configuration.model_name || controller_name.singularize).to_s
        end

        def model
          @model ||= model_name.camelize.constantize rescue nil
        end

        def view_paths_fallbacks *args
          temp = Puffer::PathSet.new view_paths
          temp._fallbacks = args.flatten
          self.view_paths = temp
        end

        def view_paths_fallbacks_prepend *args
          view_paths_fallbacks args, view_paths._fallbacks
        end

        def view_paths_fallbacks_append *args
          view_paths_fallbacks view_paths._fallbacks, args
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puffer-0.0.19 lib/puffer/controller/mutate.rb