Sha256: cc7a51a7866c48d0c146ca4adbba6fd86a2efe92214db8e051ce5c6b80c71e22
Contents?: true
Size: 857 Bytes
Versions: 3
Compression:
Stored size: 857 Bytes
Contents
module Havior class Builder def initialize @count = 0 @components = [] end def destribute name, ajax_params = {}, erb_params={} namespace = name.to_s.camelize @count += 1 klass = Module.const_get("#{namespace}::Model") obj = klass.new @count @components.push obj obj.html(ajax_params, erb_params).html_safe end def all_javascripts @components.inject([]){|acc,c|acc + c.javascripts}.uniq end def all_stylesheets @components.inject([]){|acc,c|acc + c.stylesheets}.uniq end def refer_to_javascripts all_javascripts.map{|js| "<script type='text/javascript' src='#{js}'></script>" }.join end def refer_to_stylesheets all_stylesheets.map{|css| "<link rel='stylesheet' type='text/css' href='#{css}'>" }.join end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
havior-0.1.2 | lib/havior/builder.rb |
havior-0.1.1 | lib/havior/builder.rb |
havior-0.1.0 | lib/havior/builder.rb |