Class: RailsBestPractices::Core::ModelAttributes
- Inherits:
-
Object
- Object
- RailsBestPractices::Core::ModelAttributes
- Defined in:
- lib/rails_best_practices/core/model_attributes.rb
Instance Method Summary collapse
- #add_attribute(model_name, attribute_name, attribute_type) ⇒ Object
- #get_attribute_type(model_name, attribute_name) ⇒ Object
-
#initialize ⇒ ModelAttributes
constructor
A new instance of ModelAttributes.
- #is_attribute?(model_name, attribute_name) ⇒ Boolean
Constructor Details
#initialize ⇒ ModelAttributes
Returns a new instance of ModelAttributes.
5 6 7 |
# File 'lib/rails_best_practices/core/model_attributes.rb', line 5 def initialize @attributes = {} end |
Instance Method Details
#add_attribute(model_name, attribute_name, attribute_type) ⇒ Object
9 10 11 12 |
# File 'lib/rails_best_practices/core/model_attributes.rb', line 9 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) ⇒ Object
14 15 16 17 |
# File 'lib/rails_best_practices/core/model_attributes.rb', line 14 def get_attribute_type(model_name, attribute_name) @attributes[model_name] ||= {} @attributes[model_name][attribute_name] end |
#is_attribute?(model_name, attribute_name) ⇒ Boolean
19 20 21 22 |
# File 'lib/rails_best_practices/core/model_attributes.rb', line 19 def is_attribute?(model_name, attribute_name) @attributes[model_name] ||= {} !!@attributes[model_name][attribute_name] end |