data_name(data) => "user"
 data_name(@user => :person) => :person
 data_name(@users) => :user
 data_name([@user]) => "users"
 data_name([]) => "array"
496191
def data_name(data_token)
      return unless data_token # nil or false

      return data_token.values.first if data_token.is_a?(Hash) # @user => :user

      data = data_object(data_token)

      if is_collection?(data) # data is a collection
        object_name = collection_root_name if collection_root_name
        object_name ||= data.table_name if data.respond_to?(:table_name)

        if object_name.nil? && data.respond_to?(:first)
          first = data.first
          object_name = data_name(first).to_s.pluralize if first.present?
        end

        object_name ||= data_token if data_token.is_a?(Symbol)
        object_name
      elsif is_object?(data) # data is an object
        object_name = object_root_name if object_root_name
        object_name ||= data if data.is_a?(Symbol)
        object_name ||= collection_root_name.to_s.singularize if collection_root_name
        object_name ||= data.class.respond_to?(:model_name) ? data.class.model_name.element : data.class.to_s.downcase
        object_name
      else
        data_token
      end
    end
1091850
def get_persons(self):
        
        cs = self.data["to"]["data"]
        res = [] 
        for c in cs:
            res.append(c["name"])
        return res
741145
def names_by_value(a)
      a = @data[a] if a.is_a?(String) || a.is_a?(Symbol)
      Hash[ a.map { |i| i.reverse } ]
    end
1079311
def get(*args)
      params = arguments(args).params

      if user_name = params.delete('user')
        get_request("/users/#{user_name}", params)
      else
        get_request("/user", params)
      end
    end
956833
def []=(key, value)
      obj = value.is_a?(String) ? value : YAML::dump(value)
      if exists?(key) # column already exists
        data(key).update(value: obj)
      else
        db.insert(key: key.to_s, value: obj)
      end
    end
1170299
def to_h
      Hash[
        attribute_names.
        map do |name| [
          name.to_s.gsub("@","").to_sym,  # key
          (instance_variable_get(name) rescue send(name))] # val
        end
      ]
    end
1373386
def object(data, options = {})
      @template.data, @template.root_name = extract_data_and_name(data)
      @template.root_name = options[:root] if options.has_key? :root
    end
915782
def to_a
      ary = []
      node = @first_leaf
      while node do
        ary += node.values
        node = node.next_sibling
      end

      ary
    end
594334
def child(data, options = {}, &block)
        return unless data.present? && resolve_condition(options)

        name   = is_name_value?(options[:root]) ? options[:root] : data_name(data)
        object = data_object(data)

        engine_options = @options.slice(:child_root)
        engine_options[:root] = is_collection?(object) && options.fetch(:object_root, @options[:child_root]) # child @users
        engine_options[:object_root_name] = options[:object_root] if is_name_value?(options[:object_root])

        object = { object => name } if data.is_a?(Hash) && object # child :users => :people

        engines << { create_key(name) => object_to_engine(object, engine_options, &block) }
      end
1166980
def object(template_data)
      current_data  = (@_locals[:object].nil? || template_data == false) ? template_data : @_locals[:object]
      @_data_object = data_object(current_data)
      @_root_name_data = template_data.is_a?(Hash) && !current_data.is_a?(Hash) ? template_data : current_data
      @_root_name_data = @_root_name_data.values.first if @_root_name_data.is_a?(Hash)

      # If we turn this around, `@_root_name_date ==` may trigger data to be loaded unnecessarily.
      # TODO: is nil a different semantic? otherwise don't use `false ==`, use !
      if false == @_root_name_data
        @_object_root_name = false
        @_collection_name = false
      end
    end
721425
def data
      @data ||= begin
        list = @xml.find('/e:epp/e:response/e:resData/node()').reject { |n| n.empty? }
        list.size > 1 ? list : list[0]
      end
    end
599892
def to_hash
      action = @parameters[:action]
      userid = @parameters[:userid]
      appname = @parameters[:appname] || @appname
      patientid = @parameters[:patientid]
      token = @parameters[:token] || @security_token
      parameter1 = process_date(@parameters[:parameter1]) || ''
      parameter2 = process_date(@parameters[:parameter2]) || ''
      parameter3 = process_date(@parameters[:parameter3]) || ''
      parameter4 = process_date(@parameters[:parameter4]) || ''
      parameter5 = process_date(@parameters[:parameter5]) || ''
      parameter6 = process_date(@parameters[:parameter6]) || ''
      data = Utilities::encode_data(@parameters[:data]) || ''

      {
        'Action' => action,
        'AppUserID' => userid,
        'Appname' => appname,
        'PatientID' => patientid,
        'Token' => token,
        'Parameter1' => parameter1,
        'Parameter2' => parameter2,
        'Parameter3' => parameter3,
        'Parameter4' => parameter4,
        'Parameter5' => parameter5,
        'Parameter6' => parameter6,
        'Data' => data
      }
    end
91588
def set_attribute_data(data, user)
            return {} unless self.can_write_attributes?(data, user)
            data.each_with_object(Hash.new) do | (key, value), result |
                # First we set all the attributes that are allowed

                if self.setting_attribute_is_allowed?(key.to_sym, user)
                    result[key] = value
                    public_send("#{key}=", value)
                elsif value.present?
                    # allow nested params to be specified using Rails _attributes
                    name = key.to_s.gsub(/_attributes$/,'').to_sym

                    next unless self.class.has_exported_nested_attribute?(name, user)

                    association = self.association(name)
                    if value.is_a?(Hash) && [:belongs_to,:has_one].include?(association.reflection.macro)
                        target = send(name) || association.build
                        result[name] = target.set_attribute_data(value, user)
                    elsif value.is_a?(Array) && :has_many == association.reflection.macro
                        result[name] = _set_attribute_data_from_collection(association, name, value, user)
                    end
                end
            end
        end
182233
def []=(name, value)
    name_pair = name_to_a(name).freeze
    hooks = assign(name_pair, value)
    hooks.each do |hook|
      hook.call(name_pair, value)
    end
    value
  end
1224406
def array(attr, metadata={})
      add_attribute(attr, :array, metadata)
      define_method("#{attr}=") do |arg|
        instance_variable_set("@#{attr}", Array(arg))
      end
    end
992493
def to_s
      string = "#{@name}"
      # If value is either nil or an empty array
      if @value.nil? || @value.is_a?(Array) && @value.size == 0
        string << " (#{@type}"
        string << "/#{@subtype}" if @subtype
        string << ')'
        string << ' [required]' if @required
      else
        if @type.eql?('Array')
          string << ' ='
          @value.each { |v| string << "\n  - #{v}" }
        else
          string << " = #{@value}"
        end
      end
      string << "\n"
    end
1322841
def full_name
      display_name_parts = [first_name, last_name].compact
      if display_name_parts.empty?
        username
      else
        display_name_parts.join(' ')
      end
    end