Class: Rules::PopulateDropDown

Inherits:
Rule
  • Object
show all
Defined in:
lib/question_chain/models/rules/populate_drop_down.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rule

#ui_object_id

Class Method Details

.attributes_for_apiObject



25
26
27
# File 'lib/question_chain/models/rules/populate_drop_down.rb', line 25

def self.attributes_for_api
  %w(id fire_value _type ui_object_id drop_down_target_id ui_object_attribute_check negate_value)
end

Instance Method Details



12
13
14
# File 'lib/question_chain/models/rules/populate_drop_down.rb', line 12

def drop_down_target_id
  _parent_document.drop_down_target_id
end

#fire!(value = nil, ui_objects_hash = {}) ⇒ Object



7
8
9
10
# File 'lib/question_chain/models/rules/populate_drop_down.rb', line 7

def fire!(value = nil, ui_objects_hash = {})
  # does not matter what the value is in this instance
  # it is used to get opions for the drop_down_target
end

#get_options(object_ids = []) ⇒ Object

ask the parent document to get the options



17
18
19
20
21
22
23
# File 'lib/question_chain/models/rules/populate_drop_down.rb', line 17

def get_options(object_ids = [])
  options = []
  _parent_document.get_target_drop_down_options(object_ids).each_pair do |key ,value|
    options << {:name => value, :value => key}
  end
  options.sort_by{|option| option[:name]}
end