Module: Transifex::CrudRequests::Update::InstanceMethods

Defined in:
lib/transifex/crud_requests.rb

Instance Method Summary collapse

Instance Method Details

#update(params = {}, options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/transifex/crud_requests.rb', line 65

def update(params = {}, options = {})
  if params.is_a?(Hash) && params[:i18n_type]
    if options[:trad_from_file]
      case params[:i18n_type]
      when "YML"
        params[:content] = YAML::load_file(params[:content]).to_yaml
      else
        file = File.open(params[:content], "rb")
        params[:content] = file.read
        file.close
      end
    end

    if params[:i18n_type] == "KEYVALUEJSON"
      params[:content] = params[:content].to_json
    end

    # Deal with accents
    params[:content] = params[:content].force_encoding("UTF-8")
  end

  url = CrudRequests.generate_url(self)

  Transifex.query_api(:put, url, params)
end