Class: Wallaby::ActiveRecord::ModelOperator::Permitter
- Inherits:
-
Object
- Object
- Wallaby::ActiveRecord::ModelOperator::Permitter
- Defined in:
- lib/adaptors/wallaby/active_record/model_operator/permitter.rb
Instance Method Summary collapse
- #compound_hashed_fields ⇒ Object
-
#initialize(model_decorator) ⇒ Permitter
constructor
A new instance of Permitter.
- #simple_field_names ⇒ Object
Constructor Details
#initialize(model_decorator) ⇒ Permitter
Returns a new instance of Permitter.
2 3 4 |
# File 'lib/adaptors/wallaby/active_record/model_operator/permitter.rb', line 2 def initialize(model_decorator) @model_decorator = model_decorator end |
Instance Method Details
#compound_hashed_fields ⇒ Object
15 16 17 18 |
# File 'lib/adaptors/wallaby/active_record/model_operator/permitter.rb', line 15 def compound_hashed_fields field_names = range_fields.keys + many_association_fields.map{ |_, | [:foreign_key] } Wallaby::Utils.to_hash(field_names.map{ |field_name| [ field_name, [] ] }) end |
#simple_field_names ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/adaptors/wallaby/active_record/model_operator/permitter.rb', line 6 def simple_field_names field_names = non_range_fields.keys + belongs_to_fields.map do |_, | [ [:foreign_key], [:polymorphic_type] ] end.flatten.compact field_names.reject do |field_name| [ @model_decorator.primary_key, 'created_at', 'updated_at' ].include? field_name end end |