Class: Spidy::Binder::Json
Overview
Bind json and convert to object
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Spidy::Binder::Base
Class Method Details
.let(name, *query, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spidy/binder/json.rb', line 7 def self.let(name, *query, &block) @attribute_names ||= [] @attribute_names << name return define_method(name) { json.dig(*query) } if block.nil? define_method(name) do if query.present? instance_exec(json.dig(*query), &block) else instance_exec(&block) end rescue StandardError => e fail Spidy::Binder::Error, "spidy(#{@define_name})##{name} => #{e.}" end end |