Class: REDCap::Form::Field

Inherits:
Struct
  • Object
show all
Defined in:
lib/red_cap/form/fields.rb

Direct Known Subclasses

Descriptive, File, RadioButtons, Sql, Text, Yesno

Constant Summary collapse

KEYS =
[
  :field_name,
  :form_name,
  :section_header,
  :field_type,
  :field_label,
  :select_choices_or_calculations,
  :field_note,
  :text_validation_type_or_show_slider_number,
  :text_validation_min,
  :text_validation_max,
  :identifier,
  :branching_logic,
  :required_field,
  :custom_alignment,
  :question_number,
  :matrix_group_name,
  :matrix_ranking,
  :field_annotation,
].each do |key|
  define_method key do
    attributes[key.to_s]
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, **kwargs, &block) ⇒ Object

field type inquiry methods



36
37
38
39
40
41
42
# File 'lib/red_cap/form/fields.rb', line 36

def method_missing method, *args, **kwargs, &block
  if method.to_s.ends_with?("?")
    field_type == method.to_s.chomp("?")
  else
    super
  end
end

Instance Attribute Details

#associated_fieldsObject

Returns the value of attribute associated_fields

Returns:

  • (Object)

    the current value of associated_fields



5
6
7
# File 'lib/red_cap/form/fields.rb', line 5

def associated_fields
  @associated_fields
end

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



5
6
7
# File 'lib/red_cap/form/fields.rb', line 5

def attributes
  @attributes
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



5
6
7
# File 'lib/red_cap/form/fields.rb', line 5

def options
  @options
end

Instance Method Details

#value(responses) ⇒ Object



31
32
33
# File 'lib/red_cap/form/fields.rb', line 31

def value responses
  responses[field_name]
end