Module: Forcast::Controller::RuleEngine::PollingEngine
- Extended by:
- ActiveSupport::Concern
- Included in:
- Api::PollingsController
- Defined in:
- lib/forcast/controllers/controller/rule_engine/polling_engine.rb
Instance Method Summary collapse
- #activate_polling ⇒ Object
- #create ⇒ Object
- #object_duplicate_params ⇒ Object
- #response_to_active ⇒ Object
- #set_model_rule_and_model_id_rule ⇒ Object
- #update ⇒ Object
Instance Method Details
#activate_polling ⇒ Object
59 60 61 62 63 |
# File 'lib/forcast/controllers/controller/rule_engine/polling_engine.rb', line 59 def activate_polling Polling.validate_if_work_exists_to_polling(:polling_model => @polling_model, :polling_model_id => @polling_model_id, :created_at => Time.now.strftime("%m/%d/%Y %H:%M")) end |
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/forcast/controllers/controller/rule_engine/polling_engine.rb', line 11 def create params[:polling_model] = @polling_model params[:polling_model_id] = @polling_model_id params[:active?] = false params[:execute?] = true params[:send?] = true params[:last_execution] = Time.now params[:duration_time] ||= 10 params[:review_time] ||= 30 params[:send_time] ||= 10 model_id = super if @auto_active model_id.update_columns(:active? => true) activate_polling end end |
#object_duplicate_params ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/forcast/controllers/controller/rule_engine/polling_engine.rb', line 65 def object_duplicate_params comp = Hash.new comp["polling_model"] = @polling_model comp["polling_model_id"] = @polling_model_id comp["rule_id"] = @rule_id return comp end |
#response_to_active ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/forcast/controllers/controller/rule_engine/polling_engine.rb', line 38 def response_to_active rule = @model_id.rule @polling_model = rule.rule_model @polling_model_id = rule.rule_model_id @model_id.update_columns(:active? => true, :execute? => true, :send? => true) activate_polling end |
#set_model_rule_and_model_id_rule ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/forcast/controllers/controller/rule_engine/polling_engine.rb', line 48 def set_model_rule_and_model_id_rule puts "set_modelo_and_modelo_id" rule = Rule.find(@rule_id) @polling_model = rule.rule_model @polling_model_id = rule.rule_model_id #pollings = rule.polling.where(:activo? => true) #raise Forcast::Application::Error::General.new(t("polling_exist_and_active")) if pollings.first raise Forcast::Application::Error::General.new(t("polling_exist")) if Polling.duplicate_object?(object_duplicate_params) rule.update_columns(:last_value_attr_comparable => nil) end |
#update ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/forcast/controllers/controller/rule_engine/polling_engine.rb', line 28 def update if @variable == 'active?' && @dato == 'true' response_to_active elsif params[:active?] response_to_active @datos = @datos.without("active?") end super end |