Class: Decidim::Attributes::Object
- Inherits:
 - 
      ActiveModel::Type::Value
      
        
- Object
 - ActiveModel::Type::Value
 - Decidim::Attributes::Object
 
 
- Defined in:
 - lib/decidim/attributes/object.rb
 
Overview
Custom attributes value to represent an Object.
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #primitive  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute primitive.
 
Instance Method Summary collapse
- 
  
    
      #initialize(primitive: ::Object)  ⇒ Object 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Object.
 - 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #validate_nested?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
The nested validator should be only added for those attributes that inherit from the AttributeObject::Model type.
 
Constructor Details
#initialize(primitive: ::Object) ⇒ Object
Returns a new instance of Object.
      9 10 11  | 
    
      # File 'lib/decidim/attributes/object.rb', line 9 def initialize(primitive: ::Object) @primitive = primitive end  | 
  
Instance Attribute Details
#primitive ⇒ Object (readonly)
Returns the value of attribute primitive.
      7 8 9  | 
    
      # File 'lib/decidim/attributes/object.rb', line 7 def primitive @primitive end  | 
  
Instance Method Details
#type ⇒ Object
:nodoc:
      13 14 15  | 
    
      # File 'lib/decidim/attributes/object.rb', line 13 def type # :nodoc: :object end  | 
  
#validate_nested? ⇒ Boolean
The nested validator should be only added for those attributes that inherit from the AttributeObject::Model type. Otherwise this would be also added e.g. for ActiveRecord objects which would cause unexpected validation errors.
      21 22 23 24 25  | 
    
      # File 'lib/decidim/attributes/object.rb', line 21 def validate_nested? return false unless primitive.is_a?(Class) (primitive < Decidim::AttributeObject::Model) == true end  |