Class: RudslRails::Card

Inherits:
ActionView::Base
  • Object
show all
Includes:
ERB::Util, Rudsl
Defined in:
lib/rudsl_rails.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/rudsl_rails.rb', line 9

def method_missing(method_sym, *arguments, &block)
  if method_sym.to_s.end_with?("_path") || method_sym.to_s.end_with?("_url")
    Rails.application.routes.url_helpers.send(method_sym, arguments, &block)
  else
    super
  end
end

Instance Method Details

#htmlObject



21
22
23
# File 'lib/rudsl_rails.rb', line 21

def html
  render html: node.try(:to_s).try(:html_safe)
end

#nodeObject



17
18
19
# File 'lib/rudsl_rails.rb', line 17

def node
  # implement node here
end

#render(*args) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/rudsl_rails.rb', line 25

def render(*args)
  view = ActionView::Base.new(Rails.configuration.paths['app/views'])
  view.class_eval do
    include Rails.application.routes.url_helpers
    include ApplicationHelper
  end
  view.render args.first
end