Module: RgGen::Core::Base::FeatureVariable

Included in:
Feature
Defined in:
lib/rggen/core/base/feature_variable.rb

Defined Under Namespace

Modules: IncludeMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



31
32
33
# File 'lib/rggen/core/base/feature_variable.rb', line 31

def self.extended(klass)
  klass.include(IncludeMethods)
end

Instance Method Details

#feature_array_variable_get(name) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/rggen/core/base/feature_variable.rb', line 43

def feature_array_variable_get(name)
  parent = call_parent_feature_variable_method(__method__, name)
  own = instance_variable_get(name)

  if [parent, own] in [Array, Array]
    [*parent, *own]
  else
    parent || own
  end
end

#feature_hash_array_variable_get(name) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rggen/core/base/feature_variable.rb', line 72

def feature_hash_array_variable_get(name)
  parent = call_parent_feature_variable_method(__method__, name)
  own = instance_variable_get(name)

  if [parent, own] in [Hash, Hash]
    parent
      .merge(own) { |_, parent_val, own_val| [*parent_val, *own_val] }
  else
    parent || own
  end
end

#feature_hash_variable_fetch(name, key) ⇒ Object



65
66
67
68
69
70
# File 'lib/rggen/core/base/feature_variable.rb', line 65

def feature_hash_variable_fetch(name, key)
  hash = instance_variable_get(name)
  return hash[key] if hash&.key?(key)

  call_parent_feature_variable_method(__method__, name, key)
end

#feature_hash_variable_get(name) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/rggen/core/base/feature_variable.rb', line 54

def feature_hash_variable_get(name)
  parent = call_parent_feature_variable_method(__method__, name)
  own = instance_variable_get(name)

  if [parent, own] in [Hash, Hash]
    parent.merge(own)
  else
    parent || own
  end
end

#feaure_scala_variable_get(name) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/rggen/core/base/feature_variable.rb', line 35

def feaure_scala_variable_get(name)
  if instance_variable_defined?(name)
    instance_variable_get(name)
  else
    call_parent_feature_variable_method(__method__, name)
  end
end