Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
incorporate suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
NealJMD committed Jan 31, 2017
1 parent d1341d9 commit 34ab7af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/services/member_updater.rb
Expand Up @@ -25,7 +25,7 @@ def action_kit_user_id
end

def member_attributes
@member_attributes ||= Member.new.attributes.keys.map(&:to_sym).select { |k| k != :id }
@member_attributes ||= Member.column_names.map(&:to_sym).select { |k| k != :id }
end

def belongs_in_more?(k)
Expand Down
13 changes: 6 additions & 7 deletions app/validators/action_kit_fields.rb
Expand Up @@ -68,7 +68,7 @@ class ActionKitFields < ActiveModel::Validator
).freeze

def initialize(name)
@name = name
@name = name.to_s
end

def validate(record)
Expand All @@ -84,12 +84,15 @@ def validate(record)
# Does the name match an existing ActionKit field name, else
# does it have a valid prefix ( +action_+, or +user_+ ).
def has_valid_form
# puts "--- testing #{@name}, got #{is_predefined_by_ak} || #{has_valid_prefix}"
is_predefined_by_ak || has_valid_prefix
end

def is_predefined_by_ak
ACTIONKIT_FIELDS_WHITELIST.include?(@name)
end

def self.is_predefined_by_ak(name)
ACTIONKIT_FIELDS_WHITELIST.include?(name.to_s)
new(name).is_predefined_by_ak
end

def self.has_valid_form(name)
Expand All @@ -102,10 +105,6 @@ def has_valid_characters
(@name =~ VALID_CHARS_RE).present?
end

def is_predefined_by_ak
ACTIONKIT_FIELDS_WHITELIST.include?(@name.to_s)
end

def has_valid_prefix
(@name =~ VALID_PREFIX_RE).present?
end
Expand Down

0 comments on commit 34ab7af

Please sign in to comment.