Sha256: d4241bc84e3574ef3d1209bad0b91b451abcd8527c9da5c9530faf4b61d318f7

Contents?: true

Size: 740 Bytes

Versions: 1

Compression:

Stored size: 740 Bytes

Contents

module Troo
  module Commands
    module Show
      class Resource
        include CommandHelpers

        attr_reader :id, :type

        class << self
          def dispatch(type = nil, id = nil)
            new(type, id).render
          end
        end

        def initialize(type = nil, id = nil)
          @type, @id = type, id
        end

        def render
          if resource
            presenter
          elsif no_default?
            error_no_default
          else
            error_not_found
          end
        end

        private

        def presenter
          resource.presenter.show
        end

        def error_not_found
          "#{type_capitalize} cannot be found."
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 lib/troo/commands/show/resource.rb