Skip to content

Commit

Permalink
fix styles
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKirat committed May 28, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 17c6675 commit 93d478a
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/rails-settings/base.rb
Original file line number Diff line number Diff line change
@@ -68,15 +68,15 @@ def cache_key
end

def keys
@defined_fields.map { |field| field.key }
@defined_fields.map(&:key)
end

def editable_keys
@defined_fields.reject { |field| field.readonly }.map { |field| field.key }
@defined_fields.reject(&:readonly).map(&:key)
end

def readonly_keys
@defined_fields.select { |field| field.readonly }.map { |field| field.key }
@defined_fields.select(&:readonly).map(&:key)
end

attr_reader :defined_fields
3 changes: 2 additions & 1 deletion lib/rails-settings/fields/array.rb
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@ module RailsSettings
module Fields
class Array < ::RailsSettings::Fields::Base
def convert_to_value(value)
return value unless value.kind_of?(::String)
return value unless value.is_a?(::String)

value.split(separator).reject(&:empty?).map(&:strip)
end
end
1 change: 1 addition & 0 deletions lib/rails-settings/fields/base.rb
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ def default_value

def convert
return convert_to_value(default_value) if readonly || saved_value.nil?

convert_to_value(saved_value)
end

5 changes: 3 additions & 2 deletions lib/rails-settings/fields/hash.rb
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@ module RailsSettings
module Fields
class Hash < ::RailsSettings::Fields::Base
def convert_to_value(value)
return value unless value.kind_of?(::String)
return value unless value.is_a?(::String)

load_value(value).deep_stringify_keys.with_indifferent_access
end

def load_value(value)
YAML.safe_load(value).to_h
rescue
rescue StandardError
{}
end
end

0 comments on commit 93d478a

Please sign in to comment.