Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
LICENSE
README.md
internal_name_helper.gemspec

README.md

Internal Name Helper for Active Model

Pre-Load all records from database, then generate some helper methods.

Since all records will be pre-loaded, and stored in the Rails instance. This is not suitable for large models.

Scenarios:

Plan

There are 3 plans in the Plan model

internal_name lite standard pro

Include the module in Model part

	gem 'internal_name_helper'
	class Plan < ActiveRecord::Base  
	  include InternalNameHelper::Methods
	end

The following methods will be generated

Class Methods

	Plan.lite
	Plan.standard
	Plan.pro

Instance Methods

	plan.is_lite?
	plan.is_not_lite?
	plan.is_standard?
	plan.is_not_standard?
	plan.is_pro?
	plan.is_not_pro?

Examples

	@current_plan = Plan.lite
	if @current_plan.is_lite?
	end
You can’t perform that action at this time.