Class: Editmode::ChunkValue
- Inherits:
-
Object
- Object
- Editmode::ChunkValue
- Includes:
- ActionViewExtensions::EditmodeHelper
- Defined in:
- lib/editmode/chunk_value.rb
Instance Attribute Summary collapse
-
#branch_id ⇒ Object
Returns the value of attribute branch_id.
-
#chunk_type ⇒ Object
Returns the value of attribute chunk_type.
-
#content ⇒ Object
Returns the value of attribute content.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#response ⇒ Object
Returns the value of attribute response.
-
#variable_fallbacks ⇒ Object
Returns the value of attribute variable_fallbacks.
-
#variable_values ⇒ Object
Returns the value of attribute variable_values.
Instance Method Summary collapse
- #field(field = nil) ⇒ Object
-
#initialize(identifier, **options) ⇒ ChunkValue
constructor
A new instance of ChunkValue.
Methods included from ActionViewExtensions::EditmodeHelper
#api_root_url, #api_version, #chunk_collection, #chunk_display, #chunk_field_value, #no_response_received, #render_chunk_content, #require_field_id, #variable_parse!
Constructor Details
#initialize(identifier, **options) ⇒ ChunkValue
9 10 11 12 13 14 |
# File 'lib/editmode/chunk_value.rb', line 9 def initialize(identifier, **) @identifier = identifier @branch_id = [:branch_id].presence @variable_values = [:values].presence || {} get_content end |
Instance Attribute Details
#branch_id ⇒ Object
Returns the value of attribute branch_id.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def branch_id @branch_id end |
#chunk_type ⇒ Object
Returns the value of attribute chunk_type.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def chunk_type @chunk_type end |
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def content @content end |
#identifier ⇒ Object
Returns the value of attribute identifier.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def identifier @identifier end |
#project_id ⇒ Object
Returns the value of attribute project_id.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def project_id @project_id end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def response @response end |
#variable_fallbacks ⇒ Object
Returns the value of attribute variable_fallbacks.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def variable_fallbacks @variable_fallbacks end |
#variable_values ⇒ Object
Returns the value of attribute variable_values.
5 6 7 |
# File 'lib/editmode/chunk_value.rb', line 5 def variable_values @variable_values end |
Instance Method Details
#field(field = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/editmode/chunk_value.rb', line 16 def field(field = nil) # Field ID can be a slug or field_name if chunk_type == 'collection_item' if field.present? field.downcase! field_content = content.detect {|f| f["custom_field_identifier"].downcase == field || f["custom_field_name"].downcase == field } if field_content.present? result = field_content['content'] result = variable_parse!(result, variable_fallbacks, variable_values) else raise no_response_received(field) end else raise require_field_id end else raise "undefined method field for chunk_type: #{chunk_type}" end result ||= content end |