Class: Locomotive::API::Forms::ContentTypeForm
- Defined in:
- app/api/locomotive/api/forms/content_type_form.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Attributes inherited from BaseForm
Instance Method Summary collapse
- #display_settings=(settings) ⇒ Object
-
#fields=(fields) ⇒ Object
If the current content type exists, look up the fields and add their IDs to the attributes hash.
-
#initialize(site, attributes = {}) ⇒ ContentTypeForm
constructor
A new instance of ContentTypeForm.
- #order_by=(field) ⇒ Object
- #public_submission_account_emails=(emails) ⇒ Object
-
#raw_item_template=(template) ⇒ Object
deprecated.
Methods inherited from BaseForm
attributes, attrs, define_attribute, #persisted?, #serializable_hash, #set_attribute
Constructor Details
#initialize(site, attributes = {}) ⇒ ContentTypeForm
Returns a new instance of ContentTypeForm.
24 25 26 27 |
# File 'app/api/locomotive/api/forms/content_type_form.rb', line 24 def initialize(site, attributes = {}) self.site = site super(attributes) end |
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
7 8 9 |
# File 'app/api/locomotive/api/forms/content_type_form.rb', line 7 def site @site end |
Instance Method Details
#display_settings=(settings) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'app/api/locomotive/api/forms/content_type_form.rb', line 58 def display_settings=(settings) (settings || {}).each do |k, v| if k == 'position' settings[k] = v.to_i else settings[k] = v == 'true' end end set_attribute(:display_settings, settings) end |
#fields=(fields) ⇒ Object
If the current content type exists, look up the fields and add their IDs to the attributes hash. If not, set the entries_custom_fields_attributes as-is
32 33 34 35 36 37 38 39 40 |
# File 'app/api/locomotive/api/forms/content_type_form.rb', line 32 def fields=(fields) self.entries_custom_fields_attributes = fields.map do |attrs| if field = existing_content_type.try(:find_entries_custom_field, attrs[:name]) attrs[:_id] = field._id end ContentTypeFieldForm.new(content_type_service, field, attrs).serializable_hash end end |
#order_by=(field) ⇒ Object
53 54 55 56 |
# File 'app/api/locomotive/api/forms/content_type_form.rb', line 53 def order_by=(field) field = '_position' if field == 'manually' set_attribute(:order_by, field) end |
#public_submission_account_emails=(emails) ⇒ Object
42 43 44 45 46 |
# File 'app/api/locomotive/api/forms/content_type_form.rb', line 42 def public_submission_account_emails=(emails) self.public_submission_accounts = emails.collect do |email| Locomotive::Account.where(email: email).first end.compact.map(&:id) end |
#raw_item_template=(template) ⇒ Object
deprecated
49 50 51 |
# File 'app/api/locomotive/api/forms/content_type_form.rb', line 49 def raw_item_template=(template) set_attribute(:entry_template, template) end |