Class: RademadeAdmin::Status::Toggler
- Inherits:
-
Object
- Object
- RademadeAdmin::Status::Toggler
- Defined in:
- app/services/status/toggler.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
- #init_item ⇒ Object
-
#initialize(model, id) ⇒ Toggler
constructor
A new instance of Toggler.
- #toggle ⇒ Object
Constructor Details
#initialize(model, id) ⇒ Toggler
Returns a new instance of Toggler.
8 9 10 11 |
# File 'app/services/status/toggler.rb', line 8 def initialize(model, id) @model = model @id = id end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
6 7 8 |
# File 'app/services/status/toggler.rb', line 6 def item @item end |
Instance Method Details
#init_item ⇒ Object
13 14 15 16 |
# File 'app/services/status/toggler.rb', line 13 def init_item @model_info = RademadeAdmin::Model::Graph.instance.model_info @model @item = @model_info.model.find @id end |
#toggle ⇒ Object
18 19 20 21 22 23 |
# File 'app/services/status/toggler.rb', line 18 def toggle if @model_info.hideable? @item.toggle @item.save end end |