Initializes a Resource and appends it to the Collection

 @param [Hash] attributes
   Attributes with which to initialize the new resource

 @return [Resource]
   a new Resource initialized with +attributes+

 @api public
190401
def new(attributes = {})
      resource = repository.scope { model.new(attributes) }
      self << resource
      resource
    end
748267
def collection_attributes(*attrs)
      @collection_attributes ||= []
      if attrs.any?
        @collection_attributes.map!(&:to_sym).concat(attrs).uniq!
        @collection_attributes.each { |a| setup_collection(a) }
      end
      @collection_attributes
    end
671945
def assign_all_attributes(attrs, track_changes = false)
      # Assign each attribute using setters
      attrs.each_pair do |key, value|
        key = key.to_sym

        # Track the change, since assign_all_attributes runs with no_change_tracking
        old_val = @attributes[key]
        attribute_will_change!(key, old_val) if track_changes && old_val != value

        if self.respond_to?(:"#{key}=")
          # If a method without an underscore is defined, call that.
          send(:"#{key}=", value)
        else
          # Otherwise, use the _ version
          set(key, value)
        end
      end

      # Make an id if there isn't one yet
      if @attributes[:id].nil? && persistor.try(:auto_generate_id)
        @attributes[:id] = generate_id
      end
    end
1372166
def initialize_attributes(caller, raw)
      # Save the interface and parent
      write_attribute(:parent, caller)
      write_attribute(:interface, raw)

      # Load the attributes from the interface
      load_interface_attributes(interface)

      # Get the relationships setup
      populate_relationship(:network_interfaces, interface)

      # Clear dirty and mark as existing
      clear_dirty!
      existing_record!
    end
1224406
def array(attr, metadata={})
      add_attribute(attr, :array, metadata)
      define_method("#{attr}=") do |arg|
        instance_variable_set("@#{attr}", Array(arg))
      end
    end
792075
def new_resource(attributes = nil, &block)
      if attributes.blank? && respond_to?(:params) && params.is_a?(ActionController::Parameters)
        resource_form_name = ActiveModel::Naming.singular(resource_class)
        attributes = params[resource_form_name] || params[resource_name] || {}
      end
      resource_service.new attributes, &block
    end
1177040
def attributes(instance)
      definitions.values.each_with_object({}) do |item, obj|
        key = item.target
        val = instance.send(:instance_variable_get, item.ivar)
        obj[key] = val unless null == val
      end
    end
1019178
def merge_attributes!(attributes)
      @attributes.merge!(attributes) do |_, v1, v2|
        v1 = v1.strip
        v2 = v2.strip
        v1_split = v1.shellsplit
        v2_split = v2.shellsplit
        if (v2_split - v1_split).empty? || v1_split.first(v2_split.size) == v2_split
          v1
        elsif v2_split.first(v1_split.size) == v1_split
          v2
        else
          "#{v1} #{v2}"
        end
      end
    end
357840
def init_tags
      @attr_tags = [
        InlineTag.new(SM::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
        InlineTag.new(SM::Attribute.bitmap_for(:TT),   "<tt>", "</tt>"),
        InlineTag.new(SM::Attribute.bitmap_for(:EM),   "<em>", "</em>"),
      ]
    end
399791
def load(attributes)
      raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
      @prefix_options, attributes = split_options(attributes)
      attributes.each do |key, value|
        @attributes[key.to_s] = typecast_attribute_value(key, value)
      end
      self
    end
160391
def populate_attributes
      self.class.normal_attribute_list.each do |normal_attribute|
        self.public_send "#{normal_attribute}=", raw_data[normal_attribute]
      end

      self.class.time_attribute_list.each do |time_attribute|
        time = raw_data[time_attribute]
        time = Time.parse(time) if !time.nil?
        self.public_send "#{time_attribute}=", time
      end

      self.class.collection_attribute_mappings.each do |collection_attribute, klass|
        collection = raw_data[collection_attribute] || []
        collection = {'data' => collection}
        collection = klass.response_collection(collection)
        self.public_send "#{collection_attribute}=", collection
      end
    end
287633
def _initialize(self, **resource_attributes):
        
        self._set_attributes(**resource_attributes)
        for attribute, attribute_type in list(self._mapper.items()):
            if attribute in resource_attributes and isinstance(resource_attributes[attribute], dict):
                setattr(self, attribute, attribute_type(**resource_attributes[attribute]))
1150341
function Resource(attributes) {
  this.engine = engine;
  this.name = !this.name ? this.name : this.name.toLowerCase();
  this.queryParams = {};
  this.attributes = {};
  this.load(attributes || {});
}
1118541
def update_attributes(properties_hash)
      self.class.get_class_properties.each do |property|
        key = property[:name].to_sym
        if properties_hash.has_key? key
          self.setValue(properties_hash[key], forKey:key)
        end
      end
    end
1067382
def buffer_attributes_to_hash(attributes)
      '{' + attributes.inject([]) do |extend_map, (key, attribute)|
        extend_map << (
          ":\"#{key}\" => " + if key == :class
                                '[' + attribute.map do |exp|
                                  exp[@value]
                                end.join(', ') + ']'
                              else
                                attribute[@value]
                              end
        )
      end.join(', ') + '}'
    end
799370
def add(attributes)
      level = attributes[:level].to_sym

      if valid_level?(level)
        entries << Entry.new(attributes)
      end
    end
237926
def [](attr)
      return nil unless instance_variable_defined?(:@attributes) and @attributes.is_a?(Hash)
      @attributes[attr] or (attr.is_a?(String) ? @attributes[attr.to_sym] : @attributes[attr.to_s])
    end