class Frails::Component::Abstract
Public Class Methods
after_render(*methods, &block)
click to toggle source
# File lib/frails/component/abstract.rb, line 21 def after_render(*methods, &block) set_callback :render, :after, *methods, &block end
before_render(*methods, &block)
click to toggle source
# File lib/frails/component/abstract.rb, line 17 def before_render(*methods, &block) set_callback :render, :before, *methods, &block end
new(view, path, options)
click to toggle source
# File lib/frails/component/abstract.rb, line 8 def initialize(view, path, options) @view = view @path = path @options = options expand_instance_vars end
Public Instance Methods
method_missing(method, *args, &block)
click to toggle source
rubocop:disable Lint/ShadowedException, Style/MissingRespondToMissing
Calls superclass method
# File lib/frails/component/abstract.rb, line 27 def method_missing(method, *args, &block) super rescue NoMethodError, NameError => e # the error is not mine, so just releases it as is. raise e if e.name != method begin @view.send method, *args, &block rescue NoMethodError => e raise e if e.name != method raise NoMethodError.new("undefined method `#{method}' for either #{self} or #{@view}", method) rescue NameError => e raise e if e.name != method raise NameError.new("undefined local variable `#{method}' for either #{self} or #{@view}", method) end end
Private Instance Methods
expand_instance_vars()
click to toggle source
Define instance variables for those that are already defined in the @view_context. Excludes variables starting with an underscore.
# File lib/frails/component/abstract.rb, line 53 def expand_instance_vars @view.instance_variables.each do |var| next if var.to_s.start_with?('@_') instance_variable_set var, @view.instance_variable_get(var) end end