aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/conversions.rb
Commit message (Collapse)AuthorAgeFilesLines
* hash_conversion itself does not at all depend on time extensionsAkira Matsuda2019-08-021-1/+0
|
* It may be better to explicitly require 'object/try' where we call `try`Akira Matsuda2019-08-011-0/+1
| | | | | | In most cases it works now without explicit require because it's accidentally required through active_support/core_ext/date_and_time/calculations.rb where we still call `try`, but that would stop working if we changed the Calculations implementation and remove the require call there.
* Enable autocorrect for `Lint/EndAlignment` copKoichi ITO2018-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary This PR changes .rubocop.yml. Regarding the code using `if ... else ... end`, I think the coding style that Rails expects is as follows. ```ruby var = if cond a else b end ``` However, the current .rubocop.yml setting does not offense for the following code. ```ruby var = if cond a else b end ``` I think that the above code expects offense to be warned. Moreover, the layout by autocorrect is unnatural. ```ruby var = if cond a else b end ``` This PR adds a setting to .rubocop.yml to make an offense warning and autocorrect as expected by the coding style. And this change also fixes `case ... when ... end` together. Also this PR itself is an example that arranges the layout using `rubocop -a`. ### Other Information Autocorrect of `Lint/EndAlignment` cop is `false` by default. https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443 This PR changes this value to `true`. Also this PR has changed it together as it is necessary to enable `Layout/ElseAlignment` cop to make this behavior.
* [Active Support] require_relative => requireAkira Matsuda2017-10-211-9/+9
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-011-9/+9
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-3/+3
|
* applies remaining conventions across the projectXavier Noria2016-08-061-13/+12
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-23/+23
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-2/+1
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Change the Hash.to_xml with a lamda example Justin2016-04-191-1/+1
| | | | Update 'foo'.to_xml(lambda { |options, key| options[:builder].b(key) }) to {foo: lambda { |options, key| options[:builder].b(key) }}.to_xml
* Fix nodoc to internal class error document some of themVipul A M2016-01-251-0/+2
| | | | | | | [ci skip] Fixes #20808 [Vipul A M & Julio Lopez]
* Added documentation about passing custom disallowed types to Hash#from_xml ↵Prathamesh Sonpatki2015-06-181-1/+19
| | | | [ci skip]
* Revert "remove unnecssary require of `to_param`, as `to_query` is already ↵Rafael Mendonça França2014-06-111-0/+1
| | | | | | | | | | | | | | | | | | | | | require `to_param`" Revert "No need to require to_param, it is already required in to_query.rb" This reverts commits ccdd97662e1fb00c23c90d59f65c091904959561 and d697ee14264a90a39cdbe87857656d8b314ac9b7. Reason by @jeremy: These requires are not for implementation dependency. They ensure that requiring array conversions provides to_query, to_param, and other array conversion behaviors. The fact that to_query is implemented in terms of to_param is just a coincidence. If to_query removed its to_param require, then someone requiring array conversions would no longer have to_param available. This change removes these intentional dependencies on to_param in favor of implementation side effects—an undesirable move that's susceptible to regression.
* remove unnecssary require of `to_param`, as `to_query` is already require ↵Kuldeep Aggarwal2014-06-121-1/+0
| | | | `to_param`
* Change 'a' to 'an' [ci skip]Santosh Wadghule2014-05-091-1/+1
|
* Minor grammer, code conventions fix [ci skip]Zoltan Kiss2014-03-151-2/+1
| | | | | Conflicts: activesupport/lib/active_support/core_ext/hash/conversions.rb
* [ci skip] Grammar correctionAkshay Vishnoi2014-01-141-1/+1
|
* documentation updated for Hashes [ci skip]KD2013-11-111-3/+6
|
* Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-0/+1
| | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* Minor refactor - Uses Enumerable#to_a instead of iterate and add to anPablo Cantero2013-07-271-1/+0
| | | | array
* CVE-2013-0156: Safe XML params parsing. Doesn't allow symbols or yaml.Jeremy Kemper2013-01-081-4/+23
|
* Revert "Merge branch 'master-sec'"Jeremy Kemper2013-01-081-23/+4
| | | | | This reverts commit 88cc1688d0cb828c17706b41a8bd27870f2a2beb, reversing changes made to f049016cd348627bf8db0d72382d7580bf802a79.
* CVE-2013-0156: Safe XML params parsing. Doesn't allow symbols or yaml.Jeremy Kemper2013-01-081-4/+23
|
* Refactor Hash.from_xml.Steve Klabnik + Katrina Owen2012-12-211-50/+100
| | | | | | | | | | | | Three basic refactors in this PR: * We extracted the logic into a method object. We now don't define a tone of extraneous methods on Hash, even if they were private. * Extracted blocks of the case statement into methods that do the work. This makes the logic more clear. * Extracted complicated if clauses into their own query methods. They often have two or three terms, this makes it much easier to see what they _do_. We took care not to refactor too much as to not break anything, and put comments where we suspect tests are missing. We think ActiveSupport::XMLMini might be a good candidate to move to a plugin in the future.
* Add documentation for Hash.from_xml [ci skip]HPNeo2012-12-011-0/+13
|
* Match classes without to_s conversions.Nikita Afanasenko2012-11-111-10/+10
| | | | There is no need in `value_under_case.class.to_s` conversion since case already matches classes with `Class === value_under_case`.
* Use `tag!` instead of `method_missing` in `to_xml` conversions.Nikita Afanasenko2012-11-041-2/+2
| | | | Since version `3.0.x` `Builder` caches method passed to `method_missing` each time. This commit replaces `method_missing` call with `tag!` call to prevent method redefinition on each `to_xml` call with the same builder.
* Hash Syntax changes to 1.9 formatAvnerCohen2012-10-201-1/+1
|
* let (array|hash)/conversions.rb load the extensions in ↵Xavier Noria2012-10-091-1/+3
| | | | object/to_(param|query).rb
* update AS/core_ext docs [ci skip]Francesco Rodriguez2012-09-121-1/+1
|
* Fix unbalanced braces in Hash#typecast_xml_value internal commentAlexey Vakhov2012-05-251-1/+1
|
* changed xml type datetime to dateTime, fixes #6328Angelo capilleri2012-05-231-2/+2
| | | | | | | | | XmlMini define the xml 'datatime', but according to http://www.w3.org/TR/xmlschema-2/#dateTime could be better change this to 'dateTime' with upper case letter 'T. So 'DateTime' and 'Time' are redefined from 'datetime' to 'dateTime' add the changing to the changelog
* String quotes and trailing spacesAlexey Gaziev2012-04-291-18/+18
|
* Issue #636 - Parsing an xml file with multiple records and extra attributes ↵Sidu Ponnappa2011-07-111-1/+1
| | | | (besides type) fails
* Fix bug with empty CDATA not being handled in Hash.from_xmlBradley Harris2011-04-291-1/+2
|
* files are a special case and need whitespace to be significantAndre Arko2011-04-141-1/+1
|
* gsub is not needed (thanks @fxn!)Andre Arko2011-04-141-1/+1
|
* attributes no longer disappear if a tag contains whitespaceAndre Arko2011-04-141-1/+1
| | | | | | | | | | old: Hash.from_xml("<tag foo='bar'>\n</tag>") => {"tag"=>"\n"} new: Hash.from_xml("<tag foo='bar'>\n</tag>") => {"tag"=>{"foo"=>"bar", "__content__"=>"\n"}
* corrected docs for Hash#to_xml and added examples.Nick Sutterer2011-01-061-2/+14
|
* Refactor inject use in hash conversions.Emilio Tagua2010-09-221-8/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-11/+11
| | | | 's/[ \t]*$//' -i {} \;)
* make a throwaway value equals to _ to avoid warningsSantiago Pastorino2010-07-241-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Unforce builder from ASSantiago Pastorino2010-06-011-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Move several configuration values from Hash to ActiveSupport::XmlMini, which ↵José Valim2010-04-291-100/+16
| | | | | | both Hash and Array depends on. Also, refactored ActiveModel serializers to just use ActiveSupport::XmlMini.to_tag. As consequence, if a serialized attribute is an array or a hash, it's not encoded as yaml, but as a hash or array.
* array.to_xml should be able to handle all types of data elements [#4490 ↵Neeraj Singh2010-04-291-47/+8
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Add support for a type=binary with an optional encoding=base64. If the ↵Josh Franklin2010-03-261-0/+9
| | | | | | encoding attribute is absent, the data is considered unencoded. [#2966 state:resolved]
* Merge docrailsPratik Naik2010-01-171-0/+48
|
* hash/conversions.rb needs active_support/core_ext/string/inflections because ↵Xavier Noria2010-01-011-0/+1
| | | | it uses singularize and a few others