Class: Futurism::Helpers::WrappingFuturismElement
- Inherits:
-
Object
- Object
- Futurism::Helpers::WrappingFuturismElement
- Includes:
- ActionView::Helpers, MessageVerifier
- Defined in:
- lib/futurism/helpers.rb
Overview
wraps functionality for rendering a futurism element
Instance Attribute Summary collapse
-
#broadcast_each ⇒ Object
readonly
Returns the value of attribute broadcast_each.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#data_attributes ⇒ Object
readonly
Returns the value of attribute data_attributes.
-
#eager ⇒ Object
readonly
Returns the value of attribute eager.
-
#extends ⇒ Object
readonly
Returns the value of attribute extends.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
Instance Method Summary collapse
- #dataset ⇒ Object
-
#initialize(extends:, placeholder:, options:) ⇒ WrappingFuturismElement
constructor
A new instance of WrappingFuturismElement.
- #render ⇒ Object
- #transformed_options ⇒ Object
Methods included from MessageVerifier
message_verifier, #message_verifier
Constructor Details
#initialize(extends:, placeholder:, options:) ⇒ WrappingFuturismElement
Returns a new instance of WrappingFuturismElement.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/futurism/helpers.rb', line 61 def initialize(extends:, placeholder:, options:) @extends = extends @placeholder = placeholder @eager = .delete(:eager) @broadcast_each = .delete(:broadcast_each) @controller = .delete(:controller) @html_options = .delete(:html_options) || {} @data_attributes = .fetch(:data, {}).except(:sgid, :signed_params) @model = .delete(:model) @options = data_attributes.any? ? .merge(data: data_attributes) : end |
Instance Attribute Details
#broadcast_each ⇒ Object (readonly)
Returns the value of attribute broadcast_each.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def broadcast_each @broadcast_each end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def controller @controller end |
#data_attributes ⇒ Object (readonly)
Returns the value of attribute data_attributes.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def data_attributes @data_attributes end |
#eager ⇒ Object (readonly)
Returns the value of attribute eager.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def eager @eager end |
#extends ⇒ Object (readonly)
Returns the value of attribute extends.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def extends @extends end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def @html_options end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def @options end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
59 60 61 |
# File 'lib/futurism/helpers.rb', line 59 def placeholder @placeholder end |
Instance Method Details
#dataset ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/futurism/helpers.rb', line 73 def dataset data_attributes.merge({ signed_params: signed_params, sgid: model && model.to_sgid.to_s, eager: eager.presence, broadcast_each: broadcast_each.presence, signed_controller: signed_controller }) end |
#render ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/futurism/helpers.rb', line 83 def render case extends when :li content_tag :li, placeholder, .deep_merge({data: dataset, is: "futurism-li"}) when :tr content_tag :tr, placeholder, .deep_merge({data: dataset, is: "futurism-table-row"}) else content_tag :"futurism-element", placeholder, .deep_merge({data: dataset}) end end |
#transformed_options ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/futurism/helpers.rb', line 94 def require_relative "shims/deep_transform_values" unless .respond_to? :deep_transform_values .deep_transform_values do |value| next(value) unless value.respond_to?(:to_global_id) next(value) if value.is_a?(ActiveRecord::Base) && value.new_record? value.to_global_id.to_s end end |