Giter Club home page Giter Club logo

0exp / smart_core Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 4.0 3.26 MB

[ARCHIVED] [[The project is totally redesigned as @smart-rb https://github.com/smart-rb]] Powerful set of common abstractions: Service Object (Operation), IoC Container (Dependency Container), Validation Object, Initialization DSL (and more..) (in active development)

License: MIT License

Ruby 99.92% Shell 0.08%
service-object ioc-container initialization-ds validation-dsl type-system dependency-injection and-more

smart_core's Introduction

SmartCore ยท Gem Version Build Status

[ARCHIVED] The project is totally redesigned as @smart-rb

Meetup Slides: link


Installation

gem 'smart_core'
bundle install
# --- or ---
gem install smart_core
require 'smart_core'

Completed abstractions:

  • Service Object (Operation, Functional Object);
  • IoC Container (Dependency Container);
  • Initializer (DSL);
  • Validator (Validation Layer);

Roadmap

  • Value Object (SmartCore::ValueObject (DTO) (truely immutable and comparable objects ๐Ÿ˜ˆ));
  • Schema Structure Validator (SmartCore::Schema);
  • Saga (SmartCore::Saga);
  • External Type System (SmartCore::Types);
    • Suport for Interface Type Checking (Duck-typing checker ๐Ÿค”);
  • Step-like execution behavior for SmartCore::Operation (.step, SmartCore::Railway);
  • Automatic result instantiation and handling for SmartCore::Operation;

Contributing

  • Fork it ( https://github.com/0exp/smart_core/fork )
  • Create your feature branch (git checkout -b feature/my-new-feature)
  • Commit your changes (git commit -am '[feature_context] Add some feature')
  • Push to the branch (git push origin feature/my-new-feature)
  • Create new Pull Request

License

Released under MIT License.

Authors

Rustam Ibragimov

smart_core's People

Contributors

0exp avatar akxcv avatar biow0lf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

smart_core's Issues

Usage of Operations as "railways"

Suppose I want the following behaviour:

class UserRegistration < SmartCore::Operation
  param :user

  def call
    validate
    save
  end

  private

  def validate
    UserValidation.call(user) # another Operation that returns either a Success or a Failure
  end

  def save
    # persistence logic that also returns a Success or a Failure
  end
end
UserRegistration.call(invalid_user) # => Failure(:email_invalid, :passwords_do_not_match)
UserRegistration.call(valid_user) # => Failure(:database_connection_error)
UserRegistration.call(valid_user) # => Success(persisted_user)

Only the last Success is returned, and on any Failure, the execution stops.

Could this be cleanly done with SmartCore? An example of code achieving this would be helpful. Also, I believe this to be a good use case for the library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.