Sha256: d27cbc6281fef0c2634135206e76d440a0a743c250735b8022785a1c7f7284f3
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 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 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pakyow-ui-1.0.0.rc2 | lib/pakyow/ui/recordable/attributes.rb |
pakyow-ui-1.0.0.rc1 | lib/pakyow/ui/recordable/attributes.rb |