Sha256: 8530242cf1809e34d7c8e9bcb836a86297a6ddd885733d47db0e6d4909e9f4a8

Contents?: true

Size: 866 Bytes

Versions: 11

Compression:

Stored size: 866 Bytes

Contents

module Hexp
  # Make the Hexp::Node DSL available to objects that implement `to_hexp`
  #
  # Mixing in {Hexp} has the same effect as mixing in {Hexp::DSL}, and is the
  # recommended way.
  #
  module DSL
    # The names of methods related to manipulating the list of children of a node
    CHILDREN_METHODS   = Hexp::Node::Children.public_instance_methods.freeze

    # The names of methods related to a node's attributes
    ATTRIBUTES_METHODS = Hexp::Node::Attributes.public_instance_methods.freeze

    # Methods that are defined directly in {Hexp::Node}
    NODE_METHODS = Hexp::Node.public_instance_methods(false) - [
      :to_hexp,
      :inspect
    ]

    [CHILDREN_METHODS, ATTRIBUTES_METHODS, NODE_METHODS].flatten.each do |method|
      define_method method do |*args, &blk|
        to_hexp.public_send(method, *args, &blk)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hexp-0.4.6 lib/hexp/dsl.rb
hexp-0.4.5 lib/hexp/dsl.rb
hexp-0.4.4 lib/hexp/dsl.rb
hexp-0.4.3 lib/hexp/dsl.rb
hexp-0.4.2 lib/hexp/dsl.rb
hexp-0.4.1 lib/hexp/dsl.rb
hexp-0.4.0.beta1 lib/hexp/dsl.rb
hexp-0.3.3 lib/hexp/dsl.rb
hexp-0.3.2 lib/hexp/dsl.rb
hexp-0.3.1 lib/hexp/dsl.rb
hexp-0.3.0 lib/hexp/dsl.rb