Sha256: 432f26541936f0109c49d257fc869e32074da3e6d28e85bbc2c85545ad3d29ed

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module EuGdpr
  class PersonalData
    include ActiveModel::Model

    attr_accessor :root, :options, :block

    def to_hash_with_options
      @hash ||= build_hash_with_options!
    end

    def build_hash_with_options!
      EuGdpr::PersonalDataHashBuilder.new({ :root => root, :options => options, :block => block }, { :with_options => true }).hash
    end

    def to_hash
      @hash ||= build_hash!
    end

    def build_hash!
      EuGdpr::PersonalDataHashBuilder.new({ :root => root, :options => options, :block => block }, { :with_options => false }).hash
    end

    def self.all
      EuGdpr::PersonalDataRegistry.all
    end

    def self.count
      EuGdpr::PersonalDataRegistry.count
    end

    def self.attribute_names
      [:root, :options, :block]
    end

    def self.find(id)
      all.find {|x| x.root == id.gsub('-', '/').camelize }
    end

    def id
      root.underscore.gsub('/', '-')
    end

    def to_param
      id
    end

    def to_s
      [self.class.model_name.human, root_model_human].compact.join(' - ')
    end

    def root_model_human
      return if root.nil?
      root.constantize.model_name.human
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_eu_gdpr-0.0.4 app/models/eu_gdpr/personal_data.rb