Module: Ext::UseHelper::Helpers

Defined in:
lib/ext/use_helper.rb

Instance Method Summary collapse

Instance Method Details

#javascriptsObject



54
55
56
# File 'lib/ext/use_helper.rb', line 54

def javascripts
  @__uses[:javascripts] ||= []
end

#stylesheetsObject



57
58
59
# File 'lib/ext/use_helper.rb', line 57

def stylesheets
  @__uses[:stylesheets] ||= []
end

#use(*elems) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ext/use_helper.rb', line 60

def use(*elems)
  elems.each do |elem|
    case elem
    when /\.js$/
      javascripts << elem unless javascripts.include? elem
    when /\.css$/
      stylesheets << elem unless stylesheets.include? elem
    else
      raise "Unknow type : #{elem}"
    end
  end
end

#use?(elem) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/ext/use_helper.rb', line 72

def use?(elem)
  javascripts.include? elem or stylesheets.include? elem
end