class Material::Components::Component
Attributes
options[R]
Public Class Methods
new(**options, &block)
click to toggle source
# File lib/material/concerns/components.rb, line 60 def initialize(**options, &block) @options = {} configure(**options, &block) end
Public Instance Methods
configure(**opts, &block)
click to toggle source
# File lib/material/concerns/components.rb, line 73 def configure(**opts, &block) @value = block if block_given? options.merge!(**opts) end
initialize_copy(other)
click to toggle source
Calls superclass method
# File lib/material/concerns/components.rb, line 78 def initialize_copy(other) super @options = @options.dup @value = @value.dup if @value.present? end
value_for(object)
click to toggle source
# File lib/material/concerns/components.rb, line 65 def value_for(object) value = object.instance_eval(&@value) if @value.respond_to?(:call) return value.dup if CLASSES_TO_DUPLICATE.any? { |klass| value.is_a?(klass) } value end