Sha256: a94f084ca1e056ef0463cd85d484e47d0269c72f24db5a86ce76af78c20084d9

Contents?: true

Size: 586 Bytes

Versions: 10

Compression:

Stored size: 586 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
        unless Object.const_defined?(presenter_class_name)
          Object.const_set presenter_class_name, Class.new(PushType::Presenter)
        end
        Object.const_get presenter_class_name
      end

    end

  end  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
push_type_core-0.10.4 app/models/concerns/push_type/presentable.rb
push_type_core-0.10.3 app/models/concerns/push_type/presentable.rb
push_type_core-0.10.2 app/models/concerns/push_type/presentable.rb
push_type_core-0.10.1 app/models/concerns/push_type/presentable.rb
push_type_core-0.10.0 app/models/concerns/push_type/presentable.rb
push_type_core-0.10.0.beta.5 app/models/concerns/push_type/presentable.rb
push_type_core-0.10.0.beta.3 app/models/concerns/push_type/presentable.rb
push_type_core-0.9.5 app/models/concerns/push_type/presentable.rb
push_type_core-0.9.3 app/models/concerns/push_type/presentable.rb
push_type_core-0.9.2 app/models/concerns/push_type/presentable.rb