Class: Settings

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Conversion, ActiveModel::Model, ActiveModel::Validations
Defined in:
app/models/settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(settable) ⇒ Settings

Initialises the settings adapter

Parameters:

  • settable (#settable)

    The settable object that has settings_on_rails settings.


10
11
12
# File 'app/models/settings.rb', line 10

def initialize(settable)
  @settable = settable
end

Instance Method Details

#persisted?Boolean

This causes forms for settings to be submitted using PATCH instead of POST

Returns:

  • (Boolean)

23
24
25
# File 'app/models/settings.rb', line 23

def persisted?
  true
end

#update(attributes) ⇒ Object

Update settings with the hash attributes

Parameters:

  • attributes (Hash)

    The hash who stores the new settings


17
18
19
20
# File 'app/models/settings.rb', line 17

def update(attributes)
  attributes.each { |k, v| send("#{k}=", v) }
  valid?
end