Class: Reportinator::SnippetArrayFunction
- Inherits:
-
ArrayFunction
- Object
- Base
- Function
- ArrayFunction
- Reportinator::SnippetArrayFunction
- Defined in:
- lib/reportinator/functions/array/snippet.rb
Constant Summary collapse
- PREFIXES =
[">snippet"]
Instance Method Summary collapse
Methods inherited from ArrayFunction
accepts?, #get, #set_attributes
Methods inherited from Function
parse, #parse_and_execute_value, #parse_value, #prefixes
Methods inherited from Base
config, #config, logger, #logger
Methods included from Helpers
#merge_hash, #merge_hash!, #symbolize_attributes
Instance Method Details
#find_snippet(name) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/reportinator/functions/array/snippet.rb', line 14 def find_snippet(name) snippets = [:snippets] return false unless snippets.present? return false unless snippets[name].present? snippets[name] end |
#output ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/reportinator/functions/array/snippet.rb', line 5 def output name = target name.strip! if name.instance_of? String parsed_name = parse_value(name) snippet = find_snippet(parsed_name) return "Missing Snippet" unless snippet.present? parse_snippet(snippet) end |
#parse_snippet(snippet) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/reportinator/functions/array/snippet.rb', line 21 def parse_snippet(snippet) = .dup .delete :snippets variables = values[0] parsed_variables = parse_value(variables) = merge_hash(, {variables: parsed_variables}) ValueParser.parse(snippet, ) end |