Sha256: 4168f5e2c7c9d652821489c5cb7205eb62d16bc0939d1921e295688c22172559
Contents?: true
Size: 1.24 KB
Versions: 20
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Puppet::Pops module Types # Interface implemented by a type that has InvocableMembers module TypeWithMembers # @return [InvocableMember,nil] An invocable member if it exists, or `nil` def [](member_name) raise NotImplementedError, "'#{self.class.name}' should implement #[]" end end # Interface implemented by attribute and function members module InvocableMember # Performs type checking of arguments and invokes the method that corresponds to this # method. The result of the invocation is returned # # @param receiver [Object] The receiver of the call # @param scope [Puppet::Parser::Scope] The caller scope # @param args [Array] Array of arguments. # @return [Object] The result returned by the member function or attribute # # @api private def invoke(receiver, scope, args, &block) raise NotImplementedError, "'#{self.class.name}' should implement #invoke" end end # Plays the same role as an PAttribute in the PObjectType. Provides # access to known attr_readers and plain reader methods. class AttrReader include InvocableMember def initialize(message) @message = message.to_sym end def invoke(receiver, scope, args, &block) receiver.send(@message) end end end end
Version data entries
20 entries across 20 versions & 1 rubygems