Sha256: dd44d0e888796df32360936be1e6c9aa78cbe70f2799584c3406b53fc650bb40
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module EuGdpr class PersonalDataHashBuilder include ActiveModel::Model attr_accessor :root, :options, :block def initialize(attributes, options = {}) super(attributes) @builder_options = options invoke_block end def attribute(name, options = {}) if with_options? hash[:attributes][name] = { :options => options } else hash[:attributes] << name end end def association(name, options = {}, &block) if with_options? hash[:associations][name] = { :options => options, :attributes => EuGdpr::PersonalDataHashBuilder.new(:block => block).hash } else hash[name] = EuGdpr::PersonalDataHashBuilder.new({ :block => block}, @builder_options).hash end end def hash if with_options? @hash ||= { :root => root, :options => options, :attributes => {}, :associations => {} } else @hash ||= { :attributes => [] } end end private def invoke_block self.block.call(self) end def with_options? @builder_options[:with_options] = true if @builder_options[:with_options].nil? @builder_options[:with_options] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_eu_gdpr-0.0.4 | app/builders/eu_gdpr/personal_data_hash_builder.rb |