Class: ForestAdminAgent::Services::SmartActionChecker

Inherits:
Object
  • Object
show all
Includes:
Utils, ForestAdminDatasourceToolkit::Components::Query, ForestAdminDatasourceToolkit::Components::Query::ConditionTree, ForestAdminDatasourceToolkit::Utils
Defined in:
lib/forest_admin_agent/services/smart_action_checker.rb

Constant Summary collapse

MAX_RECORDS_FOR_APPROVAL =

The Forest server's cap on approval record ids; max_records_for_approval may only lower it.

500

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters, collection, smart_action, caller, role_id, filter) ⇒ SmartActionChecker

Returns a new instance of SmartActionChecker.



43
44
45
46
47
48
49
50
51
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 43

def initialize(parameters, collection, smart_action, caller, role_id, filter)
  @parameters = parameters
  @collection = collection
  @smart_action = smart_action
  @caller = caller
  @role_id = role_id
  @filter = filter
  @attributes = parameters[:data][:attributes]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



41
42
43
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 41

def attributes
  @attributes
end

#callerObject (readonly)

Returns the value of attribute caller.



41
42
43
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 41

def caller
  @caller
end

#collectionObject (readonly)

Returns the value of attribute collection.



41
42
43
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 41

def collection
  @collection
end

#filterObject (readonly)

Returns the value of attribute filter.



41
42
43
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 41

def filter
  @filter
end

#parametersObject (readonly)

Returns the value of attribute parameters.



41
42
43
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 41

def parameters
  @parameters
end

#role_idObject (readonly)

Returns the value of attribute role_id.



41
42
43
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 41

def role_id
  @role_id
end

#smart_actionObject (readonly)

Returns the value of attribute smart_action.



41
42
43
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 41

def smart_action
  @smart_action
end

Instance Method Details

#can_execute?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
# File 'lib/forest_admin_agent/services/smart_action_checker.rb', line 53

def can_execute?
  if attributes[:signed_approval_request].nil?
    can_trigger?
  else
    can_approve?
  end
end