Class: AcroThat::Actions::AddField
- Inherits:
-
Object
- Object
- AcroThat::Actions::AddField
- Includes:
- Base
- Defined in:
- lib/acro_that/actions/add_field.rb
Overview
Action to add a new field to a PDF document Delegates to field-specific classes for actual field creation
Instance Attribute Summary collapse
-
#field_obj_num ⇒ Object
readonly
Returns the value of attribute field_obj_num.
-
#field_type ⇒ Object
readonly
Returns the value of attribute field_type.
-
#field_value ⇒ Object
readonly
Returns the value of attribute field_value.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(document, name, options = {}) ⇒ AddField
constructor
A new instance of AddField.
Methods included from Base
#acroform_ref, #apply_patch, #find_page_by_number, #get_object_body_with_patch, #next_fresh_object_number, #patches, #resolver
Constructor Details
#initialize(document, name, options = {}) ⇒ AddField
Returns a new instance of AddField.
12 13 14 15 16 17 |
# File 'lib/acro_that/actions/add_field.rb', line 12 def initialize(document, name, = {}) @document = document @name = name @options = normalize_hash_keys() @metadata = normalize_hash_keys(@options[:metadata] || {}) end |
Instance Attribute Details
#field_obj_num ⇒ Object (readonly)
Returns the value of attribute field_obj_num.
10 11 12 |
# File 'lib/acro_that/actions/add_field.rb', line 10 def field_obj_num @field_obj_num end |
#field_type ⇒ Object (readonly)
Returns the value of attribute field_type.
10 11 12 |
# File 'lib/acro_that/actions/add_field.rb', line 10 def field_type @field_type end |
#field_value ⇒ Object (readonly)
Returns the value of attribute field_value.
10 11 12 |
# File 'lib/acro_that/actions/add_field.rb', line 10 def field_value @field_value end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/acro_that/actions/add_field.rb', line 19 def call type_input = @options[:type] || "/Tx" @options[:group_id] # Auto-set radio button flags if type is :radio and flags not explicitly set # MUST set this BEFORE creating the field handler so it gets passed correctly if [:radio, "radio"].include?(type_input) && !@metadata[:Ff] @metadata[:Ff] = 49_152 end # Determine field type and create appropriate field handler field_handler = create_field_handler(type_input) # Call the field handler field_handler.call # Store field_obj_num from handler for compatibility @field_obj_num = field_handler.field_obj_num @field_type = field_handler.field_type @field_value = field_handler.field_value true end |