Sha256: 2db14d8dd8cc85d696cc192b4bbf549a7229087be087f3ad77688c373101473b

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

module <%= module_name %>

  # TODO: What does the case do?
  #
  # @example
  #     use_case = <%= class_name %>.new(TODO: TODO)
  #     use_case.subscribe some_listener
  #     use_case.run
  #
  # Methods:
  # <tt>.new</tt>:: initializes a use case with some uuid.
  # <tt>#subscribe</tt>:: subscribes listeners for <tt>#run</tt>'s notifications
  # <tt>#run</tt>:: runs a case and returns TODO or +nil+
  # <tt>#run!</tt>:: runs a case. Fails if no firm found.
  #
  # The +run+ method returns TODO (or +nil+) and notifies its listeners:
  # <tt>:TODO</tt>:: when TODO.
  #
  class <%= class_name %> < Hexx::UseCase

    # Allow necessary parameters here:
    # allow_params :some_parameter, :another_one

    # Add case-specific validations
    # validates :some_attribute, presence: true

    # Runs the case and fails if TODO.
    #
    # @example
    #     <%= class_name %>.new(TODO: TODO).run!
    #     # => #<<%= module_name %>::TODO ...>
    #
    #     <%= class_name %>.new.run!
    #     # => fails with #<TODO ...>
    #
    def run!
      validate!
      # describe other rules here
    end

    private

    # Define custom validations
    # def something_valid?
    #   return unless something
    #   errors.add :some_attribute, :some_key
    # end

    # Define virtual attributes to validate
    # def some_attribute
    #   @some_attribute ||= params["some_param"]
    # end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hexx-1.1.1 lib/generators/use_case/templates/use_case.erb