Project

faat

0.0
No commit activity in last 3 years
No release in over 3 years
Gem Faat kills your fat models.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.6
>= 0
~> 10.0
~> 3.4.0

Runtime

 Project Readme

Faat

Join the chat at https://gitter.im/xo8bit/faat Gem Version Code Climate Test Coverage Build Status

Welcome to faat gem!

Installation

Add this line to your application's Gemfile:

gem 'faat'

And then execute:

$ bundle

Or install it yourself as:

$ gem install faat

Usage

Run rails generate faat:services {service_name}, generator will create folder services in app directory, and file {service_name}_service.rb

Run rails generate faat:forms {form_name} {attribute_name}:{attribute_type}, generator will create folder forms in app directory, and file {form_name}_form.rb

###Initialize:

@post = Post.new
@post_service = PostService.new(@post)

@post_form = PostForm.new(post_form_params)

###Usage:

@post_service.destroy  => destroy @post
@post_service.update   => update @post

PostService.last     => Post.last
PostService.all      => Post.all
PostService.where(title: "First Test Title") => Post.where(...)

###Examples:

In post_services.rb

class PostService < Faat::Services::Base
    ...

    def initialize(post_form)
        @author = Author.create!(name: post_form.author_name, email: post_form.author_email)
        @post = Post.create!(text: post_form.text, title: post_form.title)
        send_confirmation_email(@author)
    end

    ...
end

Inpost_controller.rb

...
def create
    @post_form = PostForm.new(post_form_params)
    if @post_form.valid?
        @post_service = PostService.new(@post_form) => create @author and @post
    end
end

Some other usage:

@post_form = PostForm.new(post_form_params)
@post_form.valid? # or invalid?
@post_form.text => some value
@post_form.author_email => john@example.com
@ost_form.author_name => John Smith

TODO

Add spec/test auto generator

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/xo8bit/faat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.