Sha256: 95ad8826c96dc2ac636d3b2c41847483f40f312ac18a5a2b4fe3a67c70b3704f
Contents?: true
Size: 1.17 KB
Versions: 10
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require "json" require "pakyow/ui/recordable/attribute" require "pakyow/ui/recordable/helpers/client_remapping" module Pakyow module UI module Recordable # @api private class Attributes < Pakyow::Presenter::Attributes include Helpers::ClientRemapping %i([] []=).each do |method_name| define_method method_name do |*args| result = super(*args) result = case method_name when :[] Attribute.new(result) else result end result.tap do subsequent = if result.is_a?(Attribute) result else [] end @calls << [remap_for_client(method_name), args, [], subsequent] end end end def to_json(*) @calls.to_json end class << self def from_attributes(attributes) new(attributes.instance_variable_get(:@attributes)).tap { |instance| instance.instance_variable_set(:@calls, []) } end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems