Sha256: 71ca4bbe3821e6b51939b8e355708ecc6e94607312ad88589bcc8699d6d0f6d0

Contents?: true

Size: 788 Bytes

Versions: 11

Compression:

Stored size: 788 Bytes

Contents

class Disposable::Twin
  class Definition < Declarative::Definitions::Definition
    def getter
      self[:name]
    end

    def setter
      "#{self[:name]}="
    end

    # :private:
    Filter = ->(definitions, options) do
      definitions.collect do |dfn|
        next if options[:exclude]    and options[:exclude].include?(dfn[:name])
        next if options[:scalar]     and dfn[:collection]
        next if options[:collection] and ! dfn[:collection]
        next if options[:twin]       and ! dfn[:nested]
        dfn
      end.compact
    end

    require "delegate"
    class Each < SimpleDelegator
      def each(options={})
        return __getobj__ unless block_given?

        Definition::Filter.(__getobj__, options).each { |dfn| yield dfn }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
disposable-0.6.3 lib/disposable/twin/definitions.rb
disposable-0.6.2 lib/disposable/twin/definitions.rb
disposable-0.6.1 lib/disposable/twin/definitions.rb
disposable-0.6.0 lib/disposable/twin/definitions.rb
disposable-0.5.0 lib/disposable/twin/definitions.rb
disposable-0.4.7 lib/disposable/twin/definitions.rb
disposable-0.4.6 lib/disposable/twin/definitions.rb
disposable-0.4.5 lib/disposable/twin/definitions.rb
disposable-0.4.4 lib/disposable/twin/definitions.rb
disposable-0.4.3 lib/disposable/twin/definitions.rb
disposable-0.4.2 lib/disposable/twin/definitions.rb