Method: Fidgit::Element#with

Defined in:
lib/fidgit/elements/element.rb

#with(&block) ⇒ Object

Evaluate a block, just like it was a constructor block.

Raises:

  • (ArgumentError)


262
263
264
265
266
267
268
269
270
271
272
# File 'lib/fidgit/elements/element.rb', line 262

def with(&block)
  raise ArgumentError.new("Must pass a block") unless block_given?
  case block.arity
    when 1
      yield self
    when 0
      instance_methods_eval(&block)
    else
      raise "block arity must be 0 or 1"
  end
end