Sha256: 8514c019cc110bea214efa6b70d1cb3c67775d9367461979e0f7aa1132208323
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'ledger_sync/type/value' Gem.find_files('ledger_sync/type/**/*.rb').each do |path| require path end Gem.find_files('ledger_sync/resource_attribute/**/*.rb').each do |path| require path end module LedgerSync class ResourceAttribute include Fingerprintable::Mixin include SimplySerializable::Mixin attr_accessor :value attr_reader :name, :reference, :type def initialize(name:, type:, value: nil) @name = name.to_sym type = type.new if type.respond_to?(:new) && !type.is_a?(Type::Value) raise "Invalid Type: #{type}" unless type.is_a?(ActiveModel::Type::Value) @type = type @value = value end def cast(value) type.cast(value) end # This is for ActiveModel::Dirty, since we define @attributes # def forgetting_assignment; end def reference? is_a?(Reference) end def valid_with?(value:) type.valid_without_casting?(value: value) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ledger_sync-1.1.1 | lib/ledger_sync/resource_attribute.rb |