Sha256: 2fda21cbf91ad7374cefe0605564dffe00cf0adbc5da38ac82c9b463d21f2bbe
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
module Jibe module ViewHelpers def jibe *args if args.try(:last).is_a? Hash strategy = args.try(:last)[:strategy] scope = args.try(:last)[:scope] silent = args.try(:last)[:silent] restrict_to = args.try(:last)[:restrict_to] partial = args.try(:partial) end resource = "#{args.first.class.to_s.split("::").first}".downcase.pluralize data = {} data[:resource] = resource data[:strategy] = strategy if strategy data[:silent] = silent if silent if scope if scope.is_a? Array scopes = [] scope.each do |s| s = "#{s.class.name.downcase}_id=#{s.id}" unless s.is_a? String scopes.push s end data[:scope] = scopes.join(" ") elsif scope.is_a? Object data[:scope] = "#{scope.class.name.downcase}_id=#{scope.id}" else data[:scope] = scope end end data[:silent] = true if args.first.nil? html = content_tag :script, nil, type: "x-jibe", data: data html += render *args unless args.first.nil? html.html_safe end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jibe-0.0.4 | lib/jibe/view_helpers.rb |