Sha256: a9e308d7f1da104b34f72ba0d56d8e8f3a2005754d30aadb6683d9eaeea587e1
Contents?: true
Size: 772 Bytes
Versions: 1
Compression:
Stored size: 772 Bytes
Contents
class Builder def self.with_first_name(first_name) @first_name = first_name self end def self.with_last_name(last_name) @last_name = last_name self end def self.with_age(age) @age = age self end def self.with_sex(sex) @sex = sex self end def self.build props = { first_name: @first_name || 'Sally', last_name: @last_name || 'Smith', age: @age || 1, sex: @sex || 'F' } Human.new props end private class Human attr_reader :first_name, :last_name, :age, :sex def initialize(args = {}) @first_name = args[:first_name] @last_name = args[:last_name] @age = args[:age] @sex = args[:sex] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dbuilder-0.5.0 | builder.rb |