Class: Ceres::Attribute::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/ceres/attribute.rb

Instance Method Summary collapse

Constructor Details

#initialize(object, &block) ⇒ DSL

Returns a new instance of DSL.



49
50
51
52
53
# File 'lib/ceres/attribute.rb', line 49

def initialize(object, &block)
  @object = object

  self.instance_exec(&block) if block
end

Instance Method Details

#description(text) ⇒ Object



55
56
57
# File 'lib/ceres/attribute.rb', line 55

def description(text)
  @object.description = text
end

#inspector(disabled: false, &block) ⇒ Object



79
80
81
82
83
# File 'lib/ceres/attribute.rb', line 79

def inspector(disabled: false, &block)
  inspector = Ceres::Inspector.new(&block) unless disabled

  @object.inspector = inspector
end

#reader(disabled: false, **args, &block) ⇒ Object



67
68
69
70
71
# File 'lib/ceres/attribute.rb', line 67

def reader(disabled: false, **args, &block)
  reader = Ceres::Reader.new(@object, **args, &block) unless disabled

  @object.reader = reader
end

#target(symbol) ⇒ Object



59
60
61
# File 'lib/ceres/attribute.rb', line 59

def target(symbol)
  @object.target = symbol
end

#variable(symbol) ⇒ Object



63
64
65
# File 'lib/ceres/attribute.rb', line 63

def variable(symbol)
  @object.variable = symbol
end

#writer(disabled: false, &block) ⇒ Object



73
74
75
76
77
# File 'lib/ceres/attribute.rb', line 73

def writer(disabled: false, &block)
  writer = Ceres::Writer.new(@object, &block) unless disabled

  @object.writer = writer
end