码迷,mamicode.com
首页 > 数据库 > 详细

"constantize" and "with_indifferent_access" method

时间:2014-06-22 23:40:33      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   color   com   

 

 

[31] pry(main)> packages.classify
=> "Package"

[33] pry(main)> packages.classify.constantize
=> Package

[40] pry(main)> hash = {key: value}
=> {:key=>"value"}
[41] pry(main)> hash[:key]
=> "value"
[42] pry(main)> hash[key]
=> nil

[44] pry(main)> hash = {key: value}.with_indifferent_access
=> {"key"=>"value"}

[45] pry(main)> hash[:key]
=> "value"
[46] pry(main)> hash[key]
=> "value"
[47] pry(main)> hash[key]
=> "value"

[49] pry(main)> app
=> #<RecommendApp _id: 539e995277616e7f74000000, created_at: 2014-06-16 07:14:26 UTC, updated_at: 2014-06-16 07:14:26 UTC, type: 1, position: 0, app_id: BSON::ObjectId(‘53970af477616e1878d40100‘)>
                  
[50] pry(main)> app.position
=> 0

[51] pry(main)> app.read_attribute :position
=> 0

[52] pry(main)> app.type
=> 1
[53] pry(main)> app.type_human

 

"constantize" and "with_indifferent_access" method,布布扣,bubuko.com

"constantize" and "with_indifferent_access" method

标签:style   class   blog   code   color   com   

原文地址:http://www.cnblogs.com/iwangzheng/p/3800085.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!