module Cranium::AttributeDSL
Public Instance Methods
define_array_attribute(name)
click to toggle source
# File lib/cranium/attribute_dsl.rb, line 17 def define_array_attribute(name) class_eval <<-attribute_method def #{name}(*args) return @#{name} || [] if args.count.zero? @#{name} = args end attribute_method end
define_attribute(name)
click to toggle source
# File lib/cranium/attribute_dsl.rb, line 3 def define_attribute(name) class_eval <<-attribute_method def #{name}(*args) return @#{name} if args.count.zero? @#{name} = args.first end attribute_method end
define_boolean_attribute(name)
click to toggle source
# File lib/cranium/attribute_dsl.rb, line 31 def define_boolean_attribute(name) class_eval <<-attribute_method def #{name}(*args) return !!@#{name} if args.count.zero? @#{name} = !!args end attribute_method end