Class: Futurism::Helpers::WrappingFuturismElement
- Inherits:
-
Object
- Object
- Futurism::Helpers::WrappingFuturismElement
- Includes:
- ActionView::Helpers, MessageVerifier, OptionsTransformer
- 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 OptionsTransformer
Methods included from MessageVerifier
message_verifier, #message_verifier
Constructor Details
#initialize(extends:, placeholder:, options:) ⇒ WrappingFuturismElement
Returns a new instance of WrappingFuturismElement.
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/futurism/helpers.rb', line 65 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.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def broadcast_each @broadcast_each end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def controller @controller end |
#data_attributes ⇒ Object (readonly)
Returns the value of attribute data_attributes.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def data_attributes @data_attributes end |
#eager ⇒ Object (readonly)
Returns the value of attribute eager.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def eager @eager end |
#extends ⇒ Object (readonly)
Returns the value of attribute extends.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def extends @extends end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def @html_options end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def @options end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
63 64 65 |
# File 'lib/futurism/helpers.rb', line 63 def placeholder @placeholder end |
Instance Method Details
#dataset ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/futurism/helpers.rb', line 77 def dataset data_attributes.merge({ signed_params: signed_params, sgid: model && model.to_sgid(expires_in: nil).to_s, eager: eager.presence, broadcast_each: broadcast_each.presence, signed_controller: signed_controller }) end |
#render ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/futurism/helpers.rb', line 87 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
98 99 100 |
# File 'lib/futurism/helpers.rb', line 98 def () end |