class RailsBestPractices::Core::ModelAttributes
Model attributes container.
Public Class Methods
new()
click to toggle source
# File lib/rails_best_practices/core/model_attributes.rb, line 7 def initialize @attributes = {} end
Public Instance Methods
add_attribute(model_name, attribute_name, attribute_type)
click to toggle source
Add a model attribute.
@param [String] model name @param [String] attribute name @param [String] attribute type
# File lib/rails_best_practices/core/model_attributes.rb, line 16 def add_attribute(model_name, attribute_name, attribute_type) @attributes[model_name] ||= {} @attributes[model_name][attribute_name] = attribute_type end
get_attribute_type(model_name, attribute_name)
click to toggle source
Get attribute type.
@param [String] model name @param [String] attribute name @return [String] attribute type
# File lib/rails_best_practices/core/model_attributes.rb, line 26 def get_attribute_type(model_name, attribute_name) @attributes[model_name] ||= {} @attributes[model_name][attribute_name] end
is_attribute?(model_name, attribute_name)
click to toggle source
If it is a model’s attribute.
@param [String] model name @param [String] attribute name @return [Boolean] true if it is the model’s attribute
# File lib/rails_best_practices/core/model_attributes.rb, line 36 def is_attribute?(model_name, attribute_name) @attributes[model_name] ||= {} !!@attributes[model_name][attribute_name] end