<commit_before>ohm-contrib
===========

A collection of drop-in modules for Ohm.

List of modules
---------------
* `Ohm::Boundaries`
* `Ohm::Timestamping`
* `Ohm::ToHash`

Example usage
-------------

    require 'ohm'
    require 'ohm/contrib'

    class Post < Ohm::Model
      include Ohm::Timestamping
      include Ohm::ToHash
      include Ohm::Boundaries
      include Ohm::WebValidations
      include Ohm::NumberValidations

      attribute :amount
      attribute :url
      attribute :poster_email
      attribute :slug

      def validate
        # from NumberValidations
        assert_decimal :amount

        # or if you want it to be optional
        assert_decimal :amount unless amount.to_s.empty?

        # from WebValidations
        assert_slug  :slug
        assert_url   :url
        assert_email :poster_email
      end
    end

    Post.first
    Post.last
    Post.new.to_hash
    Post.create.to_hash
    Post.create.created_at
    Post.create.updated_at

    # Casting example
    class Product
      include Ohm::Typecast
      
      attribute :price, Decimal
      attribute :start_of_sale, Time
      attribute :end_of_sale, Time
      attribute :priority, Integer
      attribute :rating, Float
    end

Credits
-------
Thanks to github user gnrfan for the web validations.

Note on Patches/Pull Requests
-----------------------------
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a
  commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

Copyright
---------
Copyright (c) 2010 <NAME>. See LICENSE for details.<commit_msg>added readme for typecasting<commit_after>ohm-contrib
===========

A collection of drop-in modules for Ohm.

List of modules
---------------
* `Ohm::Boundaries`
* `Ohm::Timestamping`
* `Ohm::ToHash`
* `Ohm::WebValidations`
* `Ohm::NumberValidations`
* `Ohm::Typecast`

Example usage
-------------

    require 'ohm'
    require 'ohm/contrib'

    class Post < Ohm::Model
      include Ohm::Timestamping
      include Ohm::ToHash
      include Ohm::Boundaries
      include Ohm::WebValidations
      include Ohm::NumberValidations

      attribute :amount
      attribute :url
      attribute :poster_email
      attribute :slug

      def validate
        # from NumberValidations
        assert_decimal :amount

        # or if you want it to be optional
        assert_decimal :amount unless amount.to_s.empty?

        # from WebValidations
        assert_slug  :slug
        assert_url   :url
        assert_email :poster_email
      end
    end

    Post.first
    Post.last
    Post.new.to_hash
    Post.create.to_hash
    Post.create.created_at
    Post.create.updated_at

    # Casting example
    class Product
      include Ohm::Typecast
      
      attribute :price, Decimal
      attribute :start_of_sale, Time
      attribute :end_of_sale, Time
      attribute :priority, Integer
      attribute :rating, Float
    end

Typecasting explained
---------------------
    require 'ohm'
    require 'ohm/contrib'

    class Post < Ohm::Model
      include Ohm::Typecast

      attribute :price, Decimal
      attribute :available_at, Time
      attribute :stock, Integer
    end

    post = Post.create(:price => "10.20", :stock => "100")
    post.price.to_s == "10.20"
    # => true

    post.price * 2 == 20.40
    # => true

    post.stock / 10 == 10
    # => true
  
Credits
-------
Thanks to github user gnrfan for the web validations.

Note on Patches/Pull Requests
-----------------------------
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a
  commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

Copyright
---------
Copyright (c) 2010 <NAME>. See LICENSE for details.

{'fraction_non_alphanumeric': 0.11090092220383069, 'fraction_numerical': 0.006620950579333176, 'mean_word_length': 2.291828793774319, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6668627', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1212, 'n_words': 424}