module Card::Bootstrap::ComponentLoader

Public Instance Methods

components() click to toggle source
# File lib/card/bootstrap/component_loader.rb, line 18
def components
  path = File.expand_path "component/*.rb", __dir__
  Dir.glob(path).map do |file|
    File.basename file, ".rb"
  end
end
include_component(component) click to toggle source
# File lib/card/bootstrap/component_loader.rb, line 11
def include_component component
  component_class = to_const component.camelcase
  define_method component do |*args, &block|
    component_class.render self, *args, &block
  end
end
load_components() click to toggle source
# File lib/card/bootstrap/component_loader.rb, line 4
def load_components
  components.each do |component|
    require_relative "component/#{component}"
    include_component component
  end
end
to_const(name) click to toggle source
# File lib/card/bootstrap/component_loader.rb, line 25
def to_const name
  self.class.const_get "::Card::Bootstrap::Component::#{name.camelcase}"
end