Class: Hanami::Action::Cache::Directives Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/hanami/action/cache/directives.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Collection of value and non value directives

Since:

  • 0.3.0

Instance Method Summary collapse

Constructor Details

#initialize(*values) ⇒ Directives

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Directives.

Since:

  • 0.3.0



104
105
106
107
108
109
110
111
112
113
# File 'lib/hanami/action/cache/directives.rb', line 104

def initialize(*values)
  @directives = []
  values.each do |directive_key|
    if directive_key.is_a? Hash
      directive_key.each { |name, value| self << ValueDirective.new(name, value) }
    else
      self << NonValueDirective.new(directive_key)
    end
  end
end

Instance Method Details

#<<(directive) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



123
124
125
126
127
128
129
# File 'lib/hanami/action/cache/directives.rb', line 123

def <<(directive)
  unless directive.valid?
    raise ArgumentError.new("Unknown cache control directive: #{directive.name.inspect}")
  end

  @directives << directive
end

#each(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



117
118
119
# File 'lib/hanami/action/cache/directives.rb', line 117

def each(&block)
  @directives.each(&block)
end

#join(separator) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



141
142
143
# File 'lib/hanami/action/cache/directives.rb', line 141

def join(separator)
  values.join(separator)
end

#valuesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



133
134
135
136
137
# File 'lib/hanami/action/cache/directives.rb', line 133

def values
  @directives.delete_if do |directive|
    directive.name == :public && @directives.map(&:name).include?(:private)
  end
end