Sha256: b296bb63948a86efc39379c7e8166a2e0be673c7b8f3763206a258eadcf2e681

Contents?: true

Size: 536 Bytes

Versions: 7

Compression:

Stored size: 536 Bytes

Contents

module PushType
  module Presentable
    extend ActiveSupport::Concern

    def presenter_class
      self.class.presenter_class
    end

    def present!(context = nil)
      presenter_class.new(self, context)
    end

    module ClassMethods

      def presenter_class_name
        "#{ self.name.demodulize }Presenter"
      end

      def presenter_class
        Object.const_get presenter_class_name
      rescue NameError
        Object.const_set presenter_class_name, Class.new(PushType::Presenter)
      end

    end

  end  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
push_type_core-0.12.1 app/models/concerns/push_type/presentable.rb
push_type_core-0.12.0 app/models/concerns/push_type/presentable.rb
push_type_core-0.12.0.beta.1 app/models/concerns/push_type/presentable.rb
push_type_core-0.11.2 app/models/concerns/push_type/presentable.rb
push_type_core-0.11.1 app/models/concerns/push_type/presentable.rb
push_type_core-0.11.0.beta.2 app/models/concerns/push_type/presentable.rb
push_type_core-0.11.0.beta.1 app/models/concerns/push_type/presentable.rb