<commit_before># Characterize

Make your models behave in special ways.

Characterize is built on top of [Casting](https://github.com/saturnflyer/casting) and makes it easy to get going in Rails.

[![Build Status](https://travis-ci.org/saturnflyer/characterize.png?branch=master)](https://travis-ci.org/saturnflyer/characterize)
[![Code Climate](https://codeclimate.com/github/saturnflyer/characterize.png)](https://codeclimate.com/github/saturnflyer/characterize)
[![Coverage Status](https://coveralls.io/repos/saturnflyer/characterize/badge.png)](https://coveralls.io/r/saturnflyer/characterize)
[![Gem Version](https://badge.fury.io/rb/characterize.png)](http://badge.fury.io/rb/characterize)


## Usage

```ruby
class UsersController < ApplicationController
  characterize :user

  def show
  end
end
# the above sets a helper_method of 'user' and loads UserCharacter

class UsersController < ApplicationController
  def show
    characterize(user, display_module)
  end

  def display_module
    current_user.can_edit?(user) ? AdministratedUser : StandardUser
  end
end

# use a standard interface in your views but change the character of the object

module AdministratedUser
  def edit_link
    view.link_to('Edit', admin_user_path)
  end
end

module StandardUser<commit_msg>add default character module example<commit_after># Characterize

Make your models behave in special ways.

Characterize is built on top of [Casting](https://github.com/saturnflyer/casting) and makes it easy to get going in Rails.

[![Build Status](https://travis-ci.org/saturnflyer/characterize.png?branch=master)](https://travis-ci.org/saturnflyer/characterize)
[![Code Climate](https://codeclimate.com/github/saturnflyer/characterize.png)](https://codeclimate.com/github/saturnflyer/characterize)
[![Coverage Status](https://coveralls.io/repos/saturnflyer/characterize/badge.png)](https://coveralls.io/r/saturnflyer/characterize)
[![Gem Version](https://badge.fury.io/rb/characterize.png)](http://badge.fury.io/rb/characterize)


## Usage

```ruby
class UsersController < ApplicationController
  characterize :user

  def show
  end
end
# the above sets a helper_method of 'user' and loads UserCharacter

module UserCharacter
  def special_behavior_available_in_the_view
     # ...
  end
end

class UsersController < ApplicationController
  def show
    characterize(user, display_module)
  end

  def display_module
    current_user.can_edit?(user) ? AdministratedUser : StandardUser
  end
end

# use a standard interface in your views but change the character of the object

module AdministratedUser
  def edit_link
    view.link_to('Edit', admin_user_path)
  end
end

module StandardUser
{'fraction_non_alphanumeric': 0.10766355140186916, 'fraction_numerical': 0.0, 'mean_word_length': 5.194444444444445, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 16, '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': '582097', 'n_tokens_mistral': 846, 'n_tokens_neox': 820, 'n_words': 195}