Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active April 13, 2018 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/adbdcdc573fb77400a59a69afde09202 to your computer and use it in GitHub Desktop.
Save havenwood/adbdcdc573fb77400a59a69afde09202 to your computer and use it in GitHub Desktop.
Example for ElDoggo on #ruby IRC
class ElDogga
attr_accessor :some_attribute
def initialize
yield self
end
end
ElDogga.new do |config|
config.some_attribute = 42
end
class ElDoggo
attr_reader :some_attribute
def initialize &block
instance_eval &block
end
def some_attribute value
@some_attribute = value
end
end
ElDoggo.new do
some_attribute 42
end
class ElDoggu
attr_reader :some_attribute
def initialize
yield self
end
def some_attribute value
@some_attribute = value
end
end
ElDoggu.new do |config|
config.some_attribute 42
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment