Sha256: 5df13ff5ef30a5d24e6b61c42581f796a18d15feac64c2580b2269de3a665aa8

Contents?: true

Size: 756 Bytes

Versions: 13

Compression:

Stored size: 756 Bytes

Contents

# frozen_string_literal: true

require 'luna_park/entities/attributable'

module LunaPark
  module Entities
    # add description
    class Nested < Attributable
      def self.namespace(name, &block) # rubocop:disable Metrics/MethodLength
        serializable_attributes(name)
        comparable_attributes(name)

        namespace_class = Class.new(Nested)
        namespace_class.define_singleton_method(:name) { "Namespace:#{name}" }
        namespace_class.class_eval(&block)

        anonym_mixin = Module.new do
          attr_reader(name)

          define_method(:"#{name}=") do |input|
            instance_variable_set(:"@#{name}", namespace_class.wrap(input))
          end
        end
        include(anonym_mixin)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
luna_park-0.13.2 lib/luna_park/entities/nested.rb
luna_park-0.13.1 lib/luna_park/entities/nested.rb
luna_park-0.13.0 lib/luna_park/entities/nested.rb
luna_park-0.12.1 lib/luna_park/entities/nested.rb
luna_park-0.12.0 lib/luna_park/entities/nested.rb
luna_park-0.11.7 lib/luna_park/entities/nested.rb
luna_park-0.11.6 lib/luna_park/entities/nested.rb
luna_park-0.11.5 lib/luna_park/entities/nested.rb
luna_park-0.11.4 lib/luna_park/entities/nested.rb
luna_park-0.11.3 lib/luna_park/entities/nested.rb
luna_park-0.11.2 lib/luna_park/entities/nested.rb
luna_park-0.11.1 lib/luna_park/entities/nested.rb
luna_park-0.11.0 lib/luna_park/entities/nested.rb