Sha256: 0f6ad82e9bfde3b192afdf73b195b7d8790c2d0cafc613f5a940c02ed82d4788

Contents?: true

Size: 630 Bytes

Versions: 7

Compression:

Stored size: 630 Bytes

Contents

module PushType
  module Templatable
    extend ActiveSupport::Concern

    def template
      self.class.template_path
    end

    def template_args
      [template, self.class.template_opts.except!(:path)]
    end

    module ClassMethods

      def template(name, opts = {})
        @template_name = name
        @template_opts = opts
      end

      def template_name
        @template_name || self.name.underscore
      end

      def template_path
        File.join template_opts[:path], template_name
      end

      def template_opts
        { path: 'nodes' }.merge(@template_opts || {})
      end

    end

  end  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
push_type_core-0.3.3 app/models/concerns/push_type/templatable.rb
push_type_core-0.3.1 app/models/concerns/push_type/templatable.rb
push_type_core-0.2.1 app/models/concerns/push_type/templatable.rb
push_type_core-0.2.0 app/models/concerns/push_type/templatable.rb
push_type_core-0.2.0.beta2 app/models/concerns/push_type/templatable.rb
push_type_core-0.1.1 app/models/concerns/push_type/templatable.rb
push_type_core-0.1.0 app/models/concerns/push_type/templatable.rb