core/rails/app/models/attrib.rb
# Set a new value for this attribute onto the passed object.
# The last parameter is what area the new attribute should be placed on
Set a new value for this attribute onto the passed object.
The last parameter is what area the new attribute should be placed on
Set a new value for this attribute onto the passed object . The last parameter is what area the new attribute should be placed on
def __set(to_orig,value,target=:system)
    raise AttribReadOnly.new(self) unless writable || target != :user || to_orig.is_a?(Hash)
    kwalify_validate(value) if target == :user
    to_merge = template(value)
    to = __resolve(to_orig)
    val = Marshal.load(Marshal.dump(self.get(to,:all,true)))
    Rails.logger.debug("Attrib: Attempting to update #{name} in #{target} on #{to.class.name}:#{to.name} from #{val.inspect} to #{value.inspect} with #{to_merge.inspect}")
    Attrib.transaction do
      Rails.logger.debug("Attrib: updating #{name} in #{target} on #{to.class.name}:#{to.name} to #{value}")
      case
      when to.is_a?(Hash) then to.deep_merge(to_merge)
      when to.is_a?(Node)
        case target
        when :note then to.note_update(to_merge)
        when :discovery then to.discovery_update(to_merge)
        else to.hint_update(to_merge)
        end
        to.node_roles.order("cohort ASC").each do |nr|
          next unless RoleRequireAttrib.find_by(role_id: nr.role_id, attrib_name: self.name)
          poke(nr)
        end if target != :note && value != val
      when to.is_a?(Role)
        case target
        when :note then to.note_update(to_merge)
        else to.template_update(to_merge)
        end
        to.node_roles.order("cohort ASC").each do |nr|
          poke(nr)
        end if target != :note
      when to.is_a?(DeploymentRole)
        case target
        when :note then to.note_update(to_merge)
        when :system, :wall
          to.wall_update(to_merge)
        else
          to.data_update(to_merge)
        end
        to.noderoles.order("cohort ASC").each do |dnr|
          poke(dnr)
          dnr.children.order("cohort ASC").each do |nr|
            next unless RoleRequireAttrib.find_by(role_id: nr.role_id, attrib_name: self.name)
            poke(nr)
          end
        end if target != :note && value != val
      when to.is_a?(NodeRole)
        case target
        when :note then to.note_update(to_merge)
        when :system then to.sysdata_update(to_merge)
        when :user,:hint then to.data_update(to_merge)
        when :wall
          to.wall_update(to_merge)
        else raise("#{target} is not a valid target to write noderole data to!")
        end
        to.children.order("cohort ASC").each do |nr|
          next unless RoleRequireAttrib.find_by(role_id: nr.role_id, attrib_name: self.name)
          poke(nr)
        end if target != :note && value != val
      else raise("Cannot write attribute data to #{to.class.to_s}")
      end
    end
    to
  end
def __set ( to_orig , value , target = :system ) raise AttribReadOnly . new ( self ) unless writable || target != :user || to_orig . is_a? ( Hash ) kwalify_validate ( value ) if target == :user to_merge = template ( value ) to = __resolve ( to_orig ) val = Marshal . load ( Marshal . dump ( self . get ( to , :all , true ) ) ) Rails . logger . debug ( "Attrib: Attempting to update #{name} in #{target} on #{to.class.name}:#{to.name} from #{val.inspect} to #{value.inspect} with #{to_merge.inspect}" ) Attrib . transaction do Rails . logger . debug ( "Attrib: updating #{name} in #{target} on #{to.class.name}:#{to.name} to #{value}" ) case when to . is_a? ( Hash ) then to . deep_merge ( to_merge ) when to . is_a? ( Node ) case target when :note then to . note_update ( to_merge ) when :discovery then to . discovery_update ( to_merge ) else to . hint_update ( to_merge ) end to . node_roles . order ( "cohort ASC" ) . each do | nr | next unless RoleRequireAttrib . find_by ( role_id : nr . role_id , attrib_name : self . name ) poke ( nr ) end if target != :note && value != val when to . is_a? ( Role ) case target when :note then to . note_update ( to_merge ) else to . template_update ( to_merge ) end to . node_roles . order ( "cohort ASC" ) . each do | nr | poke ( nr ) end if target != :note when to . is_a? ( DeploymentRole ) case target when :note then to . note_update ( to_merge ) when :system , :wall to . wall_update ( to_merge ) else to . data_update ( to_merge ) end to . noderoles . order ( "cohort ASC" ) . each do | dnr | poke ( dnr ) dnr . children . order ( "cohort ASC" ) . each do | nr | next unless RoleRequireAttrib . find_by ( role_id : nr . role_id , attrib_name : self . name ) poke ( nr ) end end if target != :note && value != val when to . is_a? ( NodeRole ) case target when :note then to . note_update ( to_merge ) when :system then to . sysdata_update ( to_merge ) when :user , :hint then to . data_update ( to_merge ) when :wall to . wall_update ( to_merge ) else raise ( "#{target} is not a valid target to write noderole data to!" ) end to . children . order ( "cohort ASC" ) . each do | nr | next unless RoleRequireAttrib . find_by ( role_id : nr . role_id , attrib_name : self . name ) poke ( nr ) end if target != :note && value != val else raise ( "Cannot write attribute data to #{to.class.to_s}" ) end end to end
Set a new value for this attribute onto the passed object.
Set a new value for this attribute onto the passed object .
# Poke any noderoles bound to this node that depend on this attribute. # Poke all the noderoles that are bound to this role. # Poke all the noderoles in this deployment that get data from this deployment role.
to_orig
<not_specific>
value
<not_specific>
target
<not_specific>