class CustomFragmentCache::Fragment
Attributes
fields[R]
fields_method[R]
name[R]
opts[R]
Public Class Methods
new(name, opts)
click to toggle source
# File lib/custom_fragment_cache/fragment.rb, line 5 def initialize(name, opts) @name = name @opts = opts.with_indifferent_access @fields = {} @fields_method = :none set_fields end
Public Instance Methods
set_fields()
click to toggle source
# File lib/custom_fragment_cache/fragment.rb, line 13 def set_fields validate_fields_method if @opts[:safe_fields].present? @fields = @opts[:safe_fields].to_a @fields_method = :safe elsif @opts[:trigger_fields].present? @fields = @opts[:trigger_fields].to_a @fields_method = :trigger end end
validate_fields_method()
click to toggle source
# File lib/custom_fragment_cache/fragment.rb, line 25 def validate_fields_method if @opts.key?(:safe_fields) && @opts.key?(:trigger_fields) raise ArgumentError, "Set trigger and safe fields are not allowed together" end end