Skip to content

Version 0.2.0

Pre-release
Pre-release

Choose a tag to compare

@sleepingkingstudios sleepingkingstudios released this 15 Dec 12:51
· 197 commits to main since this release

Actions

Implemented #transaction method.

Refactored how actions handle required parameters.

  • The validation errors for the Create and Update actions are now scoped by the resource name. The error path should now match the relative path of the corresponding form field.

  • (Breaking Change) Action constructors no longer accept :repository or :resource keywords by default.

  • (Breaking Change) Actions now require a :repository keyword when called, and can accept arbitrary keywords.

  • (Breaking Change) Resource actions now require a :resource keyword when called.

Middleware

  • Defined Actions::Middleware::Associations::Find for querying associations.
  • Defined Actions::Middleware::Associations::Parent for querying a parent belongs_to association.
  • Defines Actions::Middleware::LogRequest for logging request details.
  • Defines Actions::Middleware::LogResult for logging the action result.

Collections

Implemented Collection#qualified_path, and added qualified path support to Repository.

Commands

Commands now handle invalid SQL statement exceptions by returning a failing result with a StatementInvalid error, rather than raising the exception.

Controllers

Implemented .build_request class method.

Implemented .default_format configuration option.

Refactored Cuprum::Rails::ControllerAction to Cuprum::Rails::Controllers::Action.

  • (Breaking Change) Controller actions now require a :controller argument when called.

Middleware

Implemented controller middleware.

  • Cuprum::Rails::Controllers::Middleware.
  • Cuprum::Rails::Controllers::ClassMethods::Middleware.

Updated Cuprum::Rails::Controllers::Action to apply configured middleware.

Requests

Added #context method to access the original request controller or context.

Added #member_action? method to identify requests to resourceful member actions.

Added #native_session method to lazily access the native controller session.

Added #properties method to access all request properties as a Hash.

Added #path_params method and properly handle parameters from the request path.

(Breaking Change) Renamed #method property to #http_method.

Resources

Automatically generate a Cuprum::Rails::Collection when creating a resource with a record_class but no explicit collection.

Added #actions option, which is automatically generated for singular and plural resources.

Added #parent option and associated #ancestors and #each_ancestors methods.

  • (Breaking Change) Removed Resource#collection.

Responders

Implemented Responders::Html::Resource to handle both singular and plural resources.

  • Cuprum::Rails::Responders::Html::PluralResource is now deprecated.
  • Cuprum::Rails::Responders::Html::SingularResource is now deprecated.

Updated JsonResponder to display full error messages in the development environment.

Extracted Responders::BaseResponder.

Extracted Responders::Html::Rendering.

(Breaking Change) Responders now require :controller and :request parameters on initialization.

Responses

Implemented Responses::HeadResponse.

Implemented Responses::Html::RedirectBackResponse.

Added Rails flash message support to HTML responses:

  • Responses::Html::RedirectBackResponse.
  • Responses::Html::RedirectResponse.
  • Responses::Html::RenderResponse.

Results

Implemented Cuprum::Rails::Result, which includes a #metadata property for passing contextual data such as an authentication session or page configuration.

Routes

Route helpers not accept a wildcards hash for populating route wildcards, as an alternative to calling routes.with_wildcards.

Member route methods now accept a primary key value as well as an entity, or allow the key to be passed as part of the wildcards.

RSpec

Implemented contracts for Cuprum::Rails actions:

  • Cuprum::Rails::RSpec::Contracts::Actions::CreateContracts
  • Cuprum::Rails::RSpec::Contracts::Actions::DestroyContracts
  • Cuprum::Rails::RSpec::Contracts::Actions::EditContracts
  • Cuprum::Rails::RSpec::Contracts::Actions::IndexContracts
  • Cuprum::Rails::RSpec::Contracts::Actions::NewContracts
  • Cuprum::Rails::RSpec::Contracts::Actions::ShowContracts
  • Cuprum::Rails::RSpec::Contracts::Actions::UpdateContracts

Contracts allow libraries or applications to verify their actions implement the action specifications.

Defined Cuprum::Rails::RSpec::Contracts::SerializersContracts:

  • ShouldSerailizeAttributesContract: Verifies that the specified attributes are serialized with the expected values.

Implemented Cuprum::Rails::RSpec::Matchers::BeAResultMatcher, which adds support for a #metadata property to the be_a_result matcher.

  • (Breaking Change) Existing contracts were moved into the Cuprum::Rails::RSpec::Contracts namespace and are scoped by type.
    • COMMAND_CONTRACT is now Contracts::CommandContracts::ShouldBeARailsCommandContract.
    • DEFINE_ROUTE_CONTRACT is replaced with Contracts::RoutesContracts::ShouldDefineCollectionRouteContract and ShouldDefineMemberRouteContract.

Serializers

Implemented Cuprum::Rails::Serializers::Context.

  • Refactored serializers to take a context: keyword instead of serializers:.

Implemented Cuprum::Rails::Serializers::Json::PropertiesSerializer.

  • Refactored AttributesSerializer to inherit from PropertiesSerializer. This is a breaking change for certain serializers with a block passed to .attribute.