Class: RudslRails::Card

Inherits:
Object
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers::AssetTagHelper, ActionView::Helpers::AssetUrlHelper, ActionView::Helpers::DateHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ActionView::Helpers::TranslationHelper, 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



15
16
17
18
19
20
21
# File 'lib/rudsl_rails.rb', line 15

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



27
28
29
# File 'lib/rudsl_rails.rb', line 27

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

#nodeObject



23
24
25
# File 'lib/rudsl_rails.rb', line 23

def node
  # implement node here
end

#render(*args) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/rudsl_rails.rb', line 31

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