Class: Lab42::DataClass::Proxy
- Inherits:
-
Object
- Object
- Lab42::DataClass::Proxy
- Defined in:
- lib/lab42/data_class/proxy.rb
Instance Attribute Summary collapse
-
#actual_params ⇒ Object
readonly
Returns the value of attribute actual_params.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#has_parent ⇒ Object
readonly
Returns the value of attribute has_parent.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#members ⇒ Object
readonly
Returns the value of attribute members.
-
#positionals ⇒ Object
readonly
Returns the value of attribute positionals.
Instance Method Summary collapse
- #check!(**params) ⇒ Object
- #define_class! ⇒ Object
- #init(data_class, **params) ⇒ Object
- #to_hash(data_class_instance) ⇒ Object
Instance Attribute Details
#actual_params ⇒ Object (readonly)
Returns the value of attribute actual_params.
7 8 9 |
# File 'lib/lab42/data_class/proxy.rb', line 7 def actual_params @actual_params end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/lab42/data_class/proxy.rb', line 7 def block @block end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
7 8 9 |
# File 'lib/lab42/data_class/proxy.rb', line 7 def defaults @defaults end |
#has_parent ⇒ Object (readonly)
Returns the value of attribute has_parent.
7 8 9 |
# File 'lib/lab42/data_class/proxy.rb', line 7 def has_parent @has_parent end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
7 8 9 |
# File 'lib/lab42/data_class/proxy.rb', line 7 def klass @klass end |
#members ⇒ Object (readonly)
Returns the value of attribute members.
7 8 9 |
# File 'lib/lab42/data_class/proxy.rb', line 7 def members @members end |
#positionals ⇒ Object (readonly)
Returns the value of attribute positionals.
7 8 9 |
# File 'lib/lab42/data_class/proxy.rb', line 7 def positionals @positionals end |
Instance Method Details
#check!(**params) ⇒ Object
9 10 11 12 13 |
# File 'lib/lab42/data_class/proxy.rb', line 9 def check!(**params) @actual_params = params raise ArgumentError, "missing initializers for #{_missing_initializers}" unless _missing_initializers.empty? raise ArgumentError, "illegal initializers #{_illegal_initializers}" unless _illegal_initializers.empty? end |
#define_class! ⇒ Object
15 16 17 18 19 20 |
# File 'lib/lab42/data_class/proxy.rb', line 15 def define_class! klass.module_eval(&_define_attr_reader) klass.module_eval(&_define_initializer) _define_methods klass end |
#init(data_class, **params) ⇒ Object
22 23 24 |
# File 'lib/lab42/data_class/proxy.rb', line 22 def init(data_class, **params) _init(data_class, defaults.merge(params)) end |
#to_hash(data_class_instance) ⇒ Object
26 27 28 29 30 |
# File 'lib/lab42/data_class/proxy.rb', line 26 def to_hash(data_class_instance) members .map { [_1, data_class_instance.instance_variable_get("@#{_1}")] } .to_h end |