Class: SmartManaging::Base

Inherits:
Object
  • Object
show all
Defined in:
app/managers/smart_managing/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'app/managers/smart_managing/base.rb', line 5

def initialize(controller)
  @controller = controller
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



3
4
5
# File 'app/managers/smart_managing/base.rb', line 3

def controller
  @controller
end

Instance Method Details

#attributesObject



13
14
15
# File 'app/managers/smart_managing/base.rb', line 13

def attributes
  klass.columns.map {|column| standardize(column.name)}
end

#editable_attributesObject



21
22
23
# File 'app/managers/smart_managing/base.rb', line 21

def editable_attributes
  attributes - SmartManaging::UNEDITABLE_ATTRIBUTES
end

#klassObject



17
18
19
# File 'app/managers/smart_managing/base.rb', line 17

def klass
  controller_name.classify.constantize
end

#model_symObject



25
26
27
# File 'app/managers/smart_managing/base.rb', line 25

def model_sym
  controller_name.to_s.singularize.to_sym
end

#number_of_attributesObject



9
10
11
# File 'app/managers/smart_managing/base.rb', line 9

def number_of_attributes
  attributes.size
end