Class: Liquid::Drop::Str
- Inherits:
-
String
- Object
- String
- Liquid::Drop::Str
- Defined in:
- lib/liquid/drop/str.rb,
lib/liquid/drop/str/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
-
#context ⇒ Object
writeonly
Sets the attribute context.
Class Method Summary collapse
-
.invokable?(m) ⇒ Boolean
– This is ‘.invokable?` when it comes to Liquids own source.
-
.invokable_methods ⇒ Object
–.
Instance Method Summary collapse
-
#invoke_drop(m) ⇒ Object
(also: #[])
– Invokes a method on the drop if it exist and is not blacklisted.
-
#is_a?(v) ⇒ Boolean
(also: #===)
– Mocks ‘#is_a?` so that Liquid thinks we are a drop.
-
#key?(_) ⇒ Boolean
–.
-
#liquid_method_missing(method) ⇒ Object
– Liquid version of ‘method_missing`, except it only works for Liquid and only takes the method.
-
#to_liquid ⇒ Object
–.
Instance Attribute Details
#context=(value) ⇒ Object (writeonly)
Sets the attribute context
4 5 6 |
# File 'lib/liquid/drop/str.rb', line 4 def context=(value) @context = value end |
Class Method Details
.invokable?(m) ⇒ Boolean
– This is ‘.invokable?` when it comes to Liquids own
source. We change it to discourage users from overriding
the methods because this is a wrapper.
–
50 51 52 |
# File 'lib/liquid/drop/str.rb', line 50 def self.invokable?(m) invokable_methods.include?(m.to_s) end |
.invokable_methods ⇒ Object
–
55 56 57 58 59 |
# File 'lib/liquid/drop/str.rb', line 55 def self.invokable_methods @invokable_methods ||= begin Set.new(good.map(&:to_s)) end end |
Instance Method Details
#invoke_drop(m) ⇒ Object Also known as: []
– Invokes a method on the drop if it exist and is
not blacklisted. We blacklist most methods by
default if it's on `String`, `Array`, `Enumberable`
`Hash` and this own class...
–
31 32 33 |
# File 'lib/liquid/drop/str.rb', line 31 def invoke_drop(m) self.class.invokable?(m) ? send(m) : liquid_method_missing(m) end |
#is_a?(v) ⇒ Boolean Also known as: ===
– Mocks ‘#is_a?` so that Liquid thinks we are a
drop. If it ever decides to ask.
–
10 11 12 |
# File 'lib/liquid/drop/str.rb', line 10 def is_a?(v) v == Liquid::Drop || super(v) end |
#key?(_) ⇒ Boolean
–
41 42 43 |
# File 'lib/liquid/drop/str.rb', line 41 def key?(_) true end |
#liquid_method_missing(method) ⇒ Object
– Liquid version of ‘method_missing`, except it only
works for Liquid and only takes the method.
–
19 20 21 22 23 |
# File 'lib/liquid/drop/str.rb', line 19 def liquid_method_missing(method) return nil unless @context && @context.strict_variables raise Liquid::UndefinedDropMethod, \ "undefined method #{method}" end |
#to_liquid ⇒ Object
–
36 37 38 |
# File 'lib/liquid/drop/str.rb', line 36 def to_liquid self end |