Sha256: cf7ac728c4311ad229ac1794bbe207ac1f04dd972073c4843f8211501d078604

Contents?: true

Size: 776 Bytes

Versions: 9

Compression:

Stored size: 776 Bytes

Contents

module FactoryBurgers
  module Presenters
    # Presenter classes are responsible for formatting application object data for
    # the UI. This defatul presenter will display the id and name attributes, if
    # they exist, and does not have an application link. Create subclasses of this
    # class to present different information for different application models.
    class Base
      class << self
        def presents(name)
          define_method(name) { object }
        end
      end

      attr_reader :object

      def initialize(object)
        @object = object
      end

      def type
        object.class.name
      end

      def attributes
        object.attributes.slice("id", "name")
      end

      def link_path
        nil
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
factory_burgers-1.1.3 lib/factory_burgers/presenters/base.rb
factory_burgers-1.1.2 lib/factory_burgers/presenters/base.rb
factory_burgers-1.1.1 lib/factory_burgers/presenters/base.rb
factory_burgers-1.1.0 lib/factory_burgers/presenters/base.rb
factory_burgers-1.0.0 lib/factory_burgers/presenters/base.rb
factory_burgers-0.1.5 lib/factory_burgers/presenters/base.rb
factory_burgers-0.1.4 lib/factory_burgers/presenters/base.rb
factory_burgers-0.1.2 lib/factory_burgers/presenters/base.rb
factory_burgers-0.1.0 lib/factory_burgers/presenters/base.rb