Module: Settings::Setting::Assignment::Attribute

Extended by:
Settings::Setting::Assignment
Defined in:
lib/settings/setting/assignment.rb

Class Method Summary collapse

Methods included from Settings::Setting::Assignment

assign, assign_value, assignable?, setter_name, setting?

Class Method Details

.assure_settable(receiver, attribute, strict = true) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/settings/setting/assignment.rb', line 55

def self.assure_settable(receiver, attribute, strict=true)
  if strict
    setting = setting? receiver, attribute
    unless setting
      raise "Can't set \"#{attribute}\". It isn't a setting of #{receiver.class.name}."
    end
  end

  assignable = assignable?(receiver, attribute)
  unless assignable
    raise "Can't set \"#{attribute}\". It isn't assignable to #{receiver.class.name}."
  end

  true
end