Class: ChoronSupport::Props::Private::Setting
- Inherits:
-
Object
- Object
- ChoronSupport::Props::Private::Setting
- Defined in:
- lib/choron_support/props/private/setting.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- SETTING_ATTRIBUTES =
%i[method name to cast default if block].freeze
Instance Method Summary collapse
-
#initialize(params) ⇒ Setting
constructor
A new instance of Setting.
- #set_default? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Setting
Returns a new instance of Setting.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/choron_support/props/private/setting.rb', line 10 def initialize(params) # 不正なオプションがあれば例外を発生させる if (params.keys - SETTING_ATTRIBUTES).present? raise Error, "invalid params: #{(params.keys - SETTING_ATTRIBUTES).join(', ')}, valid params are #{SETTING_ATTRIBUTES.join(', ')}" end @method = params[:method] @name = params[:name] || @method @to = params[:to] || :model @cast = params[:cast] @default = params[:default] || NO_DEFAULT @if = params[:if] || nil @block = params[:block] || nil check_params! end |
Instance Method Details
#set_default? ⇒ Boolean
28 29 30 |
# File 'lib/choron_support/props/private/setting.rb', line 28 def set_default? default != NO_DEFAULT end |