Class: RademadeAdmin::Status::Toggler

Inherits:
Object
  • Object
show all
Defined in:
app/services/status/toggler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#itemObject (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_itemObject



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

#toggleObject



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