• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Powerful, flexible and configurable coercion library. And nothing more.

Coercible

Gem Version Build Status Dependency Status Code Climate Test Coverage Inline docs

Installation

Add this line to your application's Gemfile:

gem 'coercible'

And then execute:

$ bundle

Or install it yourself as:

$ gem install coercible

Usage

Coercible gives you access to coercer objects where each object is responsible for coercing only one type into other types. For example a string coercer knows only how to coerce string objects, integer coercer knows only how to coerce integers etc.

Here's the most basic example:

coercer = Coercible::Coercer.new

# coerce a string to a date
coercer[String].to_date('2012/12/25') # => #<Date: 4912573/2,0,2299161>

# coerce a string to a boolean value
coercer[String].to_boolean('yes') # => true

# you got the idea :)

For more control you can configure your coercer like that:

# build coercer instance
coercer = Coercible::Coercer.new do |config|
  config.string.boolean_map = { 'yup' => true, 'nope' => false }
end

# coerce a string to boolean
coercer[String].to_boolean('yup') # => true
coercer[String].to_boolean('nope') # => false

Note that at the moment only Integer and String are configurable. More configurable coercers will be added later whenever we find good usecases.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

More Repositories

1

virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
Ruby
3,767
star
2

transproc

The project was ported to dry-rb/dry-transformer
Ruby
410
star
3

rom-relation

This is an old ROM prototype that's no longer developed.
Ruby
363
star
4

transflow

[DISCONTINUED] Business transaction flow DSL
Ruby
101
star
5

charlatan

Neat delegation for ruby objects
Ruby
69
star
6

rom-rails-skeleton

My Rails app skeleton with ROM and other goodies
Ruby
35
star
7

rom-session

DEPRECATED / DEAD / MOVE ON
Ruby
33
star
8

hanami-api-system-template

⚠️ [WIP] ⚠️ hanami-api + dry-system + rom application template
Ruby
18
star
9

hanami-bookshelf-rom

Hanami 1.x bookshelf app based on tutorial, tweaked to use rom-rb 4.x standalone
Ruby
18
star
10

dm-validations-ext

Various additions to the dm-validations API
Ruby
12
star
11

rom-rails-demo

Experimental rails app demo using ROM
Ruby
10
star
12

ossy

Maintenance automation helper as a CLI tool used by dry-rb and rom-rb
Ruby
9
star
13

lotuskase

Custom web stack based on dry-component and lotus
Ruby
8
star
14

architecture-talk-example-app

Ruby
7
star
15

hanami-dockerized-demo

A sample Hanami app with a docker-compose-driven-development-and-CI aka one docker-compose to rule them all.
Ruby
7
star
16

virtus-dirty_tracking

ABANDONED - MOVE ON
Ruby
6
star
17

rom-workshop

Ruby
5
star
18

dm-timezones

Timezones support for DataMapper
5
star
19

dm-is-formattable

Ruby
3
star
20

rodakase

The project that gave birth to dry-(system|view|web)
Ruby
2
star
21

middleman-docsite

Various middleman extensions extracted from rom-rb and dry-rb websites
Ruby
2
star
22

docker-nginx-proxy-example

JavaScript
2
star
23

dm-is-configurable

A DataMapper plugin which adds configuration to resources
Ruby
2
star
24

ruby-devel-containers

WIP
Ruby
1
star
25

dm-gdata-adapters

A set of DataMapper adapters for Google Data API
Ruby
1
star
26

virtus-units

ABANDONED - MOVE ON
Ruby
1
star