Class: Concerns::Storable::Config
- Inherits:
-
Object
- Object
- Concerns::Storable::Config
- Defined in:
- app/models/concerns/storable/config.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #add(field, type, default = nil) ⇒ Object
- #allowed?(field) ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 |
# File 'app/models/concerns/storable/config.rb', line 6 def initialize @fields = {} end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
4 5 6 |
# File 'app/models/concerns/storable/config.rb', line 4 def fields @fields end |
Instance Method Details
#add(field, type, default = nil) ⇒ Object
10 11 12 |
# File 'app/models/concerns/storable/config.rb', line 10 def add(field, type, default = nil) @fields[field.to_sym] = { type: type, default: default } end |
#allowed?(field) ⇒ Boolean
14 15 16 |
# File 'app/models/concerns/storable/config.rb', line 14 def allowed?(field) @fields.keys.include?(field.to_sym) end |