Module: Cranium::AttributeDSL
- Included in:
- DSL::DatabaseDefinition, DSL::ExtractDefinition, DSL::ImportDefinition, DSL::SourceDefinition
- Defined in:
- lib/cranium/attribute_dsl.rb
Instance Method Summary collapse
- #define_array_attribute(name) ⇒ Object
- #define_attribute(name) ⇒ Object
- #define_boolean_attribute(name) ⇒ Object
Instance Method Details
#define_array_attribute(name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# 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) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# 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) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# 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 |