Class: Props::Options
- Inherits:
-
Hash
- Object
- Hash
- Props::Options
show all
- Defined in:
- lib/props_template/options.rb
Defined Under Namespace
Classes: InvalidOptionError
Instance Method Summary
collapse
Instance Method Details
#cache(id_or_block) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/props_template/options.rb', line 22
def cache(id_or_block)
return unless id_or_block
self[:cache] = id_or_block
self
end
|
#defer(type, placeholder: {}, **opts) ⇒ Object
10
11
12
13
|
# File 'lib/props_template/options.rb', line 10
def defer(type, placeholder: {}, **opts)
self[:defer] = [type, {placeholder: placeholder}.merge(opts)]
self
end
|
#fragment(fragment) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/props_template/options.rb', line 15
def fragment(fragment)
raise "Fragment can't be defined without a partial. Please use `partial` first" if !self[:partial]
self[:partial][1][:fragment] = fragment
self
end
|
#id_key(key_name) ⇒ Object
29
30
31
32
|
# File 'lib/props_template/options.rb', line 29
def id_key(key_name)
self[:key] = key_name
self
end
|
#partial(partial_name, opts = {}) ⇒ Object
5
6
7
8
|
# File 'lib/props_template/options.rb', line 5
def partial(partial_name, opts = {})
self[:partial] = [partial_name, opts]
self
end
|
#valid_for_set! ⇒ Object
34
35
36
37
|
# File 'lib/props_template/options.rb', line 34
def valid_for_set!
raise InvalidOptionError.new("Props::Options can't be empty") if empty?
raise InvalidOptionError.new("The partial option must be used with an inline `set!`") if !key?(:partial)
end
|