Class: ConstructorIORails::Fields
- Inherits:
-
Object
- Object
- ConstructorIORails::Fields
- Includes:
- Singleton
- Defined in:
- lib/constructorio-rails/fields.rb
Instance Attribute Summary collapse
-
#set ⇒ Object
Returns the value of attribute set.
Instance Method Summary collapse
- #add(model_name, field) ⇒ Object
-
#initialize ⇒ Fields
constructor
A new instance of Fields.
- #list(model_name) ⇒ Object
Constructor Details
#initialize ⇒ Fields
Returns a new instance of Fields.
9 10 11 |
# File 'lib/constructorio-rails/fields.rb', line 9 def initialize @set = {} end |
Instance Attribute Details
#set ⇒ Object
Returns the value of attribute set.
7 8 9 |
# File 'lib/constructorio-rails/fields.rb', line 7 def set @set end |
Instance Method Details
#add(model_name, field) ⇒ Object
13 14 15 16 |
# File 'lib/constructorio-rails/fields.rb', line 13 def add(model_name, field) @set[model_name] ||= {} @set[model_name][field] = 1 end |
#list(model_name) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/constructorio-rails/fields.rb', line 18 def list(model_name) if @set[model_name].is_a?(Hash) @set[model_name].keys else [] end end |