Class: RgGen::Core::InputBase::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/core/input_base/property.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options, &body) ⇒ Property

Returns a new instance of Property.



11
12
13
14
15
16
17
18
19
20
# File 'lib/rggen/core/input_base/property.rb', line 11

def initialize(name, options, &body)
  @name = name
  @options = options
  @costom_property =
    if options[:body]
      create_costom_property(&options[:body])
    elsif block_given?
      create_costom_property(&body)
    end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/rggen/core/input_base/property.rb', line 22

def name
  @name
end

Class Method Details

.define(feature, name, **options, &body) ⇒ Object



7
8
9
# File 'lib/rggen/core/input_base/property.rb', line 7

def self.define(feature, name, **options, &body)
  new(name, options, &body).define(feature)
end

Instance Method Details

#define(feature) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/rggen/core/input_base/property.rb', line 24

def define(feature)
  feature.class_exec(self) do |property|
    define_method(property.name) do |*args, **kwargs, &block|
      property.evaluate(self, *args, **kwargs, &block)
    end
  end
end

#evaluate(feature) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/rggen/core/input_base/property.rb', line 32

def evaluate(feature, ...)
  feature.verify(@options[:verify]) if @options.key?(:verify)
  if proxy_property?
    proxy_property(feature, ...)
  else
    default_property(feature)
  end
end