Class: ForestLiana::Model::Action
- Inherits:
-
Object
- Object
- ForestLiana::Model::Action
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Serialization, ActiveModel::Validations
- Defined in:
- app/models/forest_liana/model/action.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#description ⇒ Object
Returns the value of attribute description.
-
#download ⇒ Object
Returns the value of attribute download.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#hooks ⇒ Object
Returns the value of attribute hooks.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#redirect ⇒ Object
Returns the value of attribute redirect.
-
#submit_button_label ⇒ Object
Returns the value of attribute submit_button_label.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Action
constructor
A new instance of Action.
- #persisted? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Action
Returns a new instance of Action.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/forest_liana/model/action.rb', line 10 def initialize(attributes = {}) if attributes.key?(:global) FOREST_LOGGER.error "REMOVED OPTION: The support for Smart Action \"global\" option is now " \ "removed. Please set \"type: 'global'\" instead of \"global: true\" for the " \ "\"#{attributes[:name]}\" Smart Action." end if attributes.key?(:type) && !['bulk', 'global', 'single'].include?(attributes[:type]) FOREST_LOGGER.warn "Please set a valid Smart Action type (\"bulk\", \"global\" or " \ "\"single\") for the \"#{attributes[:name]}\" Smart Action." end attributes.each do |name, value| send("#{name}=", value) end @fields ||= [] has_fields_without_name = false @fields.delete_if do |field| if field.key?(:field) false else has_fields_without_name = true true end end @fields.map! do |field| if field.key?(:isRequired) FOREST_LOGGER.warn "DEPRECATION WARNING: isRequired on field \"#{field[:field]}\" is deprecated. Please use is_required." field[:is_required] = !!field[:isRequired] field.delete(:isRequired) end if field.key?(:isReadOnly) FOREST_LOGGER.warn "DEPRECATION WARNING: isReadOnly on field \"#{field[:field]}\" is deprecated. Please use is_read_only." field[:is_read_only] = !!field[:isReadOnly] field.delete(:isReadOnly) end field[:type] = "String" unless field.key?(:type) field[:default_value] = nil unless field.key?(:default_value) field[:enums] = nil unless field.key?(:enums) field[:is_required] = false unless field.key?(:is_required) field[:is_read_only] = false unless field.key?(:is_read_only) field[:reference] = nil unless field.key?(:reference) field[:description] = nil unless field.key?(:description) field[:widget] = nil unless field.key?(:widget) field end if has_fields_without_name FOREST_LOGGER.warn "Please set a name to all your \"#{@name}\" Smart Action fields " \ "(Smart Actions fields without name are ignored)." end dasherized_name = ActiveSupport::Inflector.parameterize(@name) unless @name.nil? @endpoint ||= "forest/actions/#{dasherized_name}" unless dasherized_name.nil? @http_method ||= "POST" @redirect ||= nil @base_url ||= nil @type ||= "bulk" @download ||= false @hooks = !@hooks.nil? ? @hooks.symbolize_keys : nil @description ||= nil @submit_button_label ||= nil end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def base_url @base_url end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def description @description end |
#download ⇒ Object
Returns the value of attribute download.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def download @download end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def endpoint @endpoint end |
#fields ⇒ Object
Returns the value of attribute fields.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def fields @fields end |
#hooks ⇒ Object
Returns the value of attribute hooks.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def hooks @hooks end |
#http_method ⇒ Object
Returns the value of attribute http_method.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def http_method @http_method end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def name @name end |
#redirect ⇒ Object
Returns the value of attribute redirect.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def redirect @redirect end |
#submit_button_label ⇒ Object
Returns the value of attribute submit_button_label.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def @submit_button_label end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'app/models/forest_liana/model/action.rb', line 7 def type @type end |
Instance Method Details
#persisted? ⇒ Boolean
81 82 83 |
# File 'app/models/forest_liana/model/action.rb', line 81 def persisted? false end |