class AngularSprinkles::ContentYielder

Public Class Methods

new(args) click to toggle source
# File lib/angular_sprinkles/content_yielder.rb, line 3
def initialize(args)
  @context = args.fetch(:context)
  @yield_to = args.fetch(:yield_to)
  @cache = args.fetch(:cache)
end

Public Instance Methods

call(content) click to toggle source
# File lib/angular_sprinkles/content_yielder.rb, line 9
def call(content)
  return '' if @cache.set?(content)

  @cache.set(content)

  @context.content_tag(:script, content.to_json.html_safe).tap do |script_tag|
    @context.content_for(@yield_to, script_tag)
  end
end