Class: ConstructorIORails::Fields

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/constructorio-rails/fields.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFields

Returns a new instance of Fields.



9
10
11
# File 'lib/constructorio-rails/fields.rb', line 9

def initialize
  @set = {}
end

Instance Attribute Details

#setObject

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