Class: SmartCore::Validator::Attribute Private
- Inherits:
-
Object
- Object
- SmartCore::Validator::Attribute
- Defined in:
- lib/smart_core/validator/attribute.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #name ⇒ Symbol readonly private
Instance Method Summary collapse
- #default_value ⇒ Any private
- #dup ⇒ SmartCore::Validator::Attribute private
- #initialize(name, default_value = nil) ⇒ void constructor private
Constructor Details
#initialize(name, default_value = nil) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/smart_core/validator/attribute.rb', line 18 def initialize(name, default_value = nil) unless name.is_a?(Symbol) || name.is_a?(String) raise( SmartCore::Validator::IncorrectAttributeNameError, 'Attribute name should be a symbol or a string' ) end @name = name.to_sym @default_value = default_value end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/smart_core/validator/attribute.rb', line 10 def name @name end |
Instance Method Details
#default_value ⇒ Any
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/smart_core/validator/attribute.rb', line 34 def default_value @default_value.is_a?(Proc) ? @default_value.call : @default_value end |
#dup ⇒ SmartCore::Validator::Attribute
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/smart_core/validator/attribute.rb', line 42 def dup self.class.new(name, @default_value) end |