In mongoid, a ORM mapped database object is like below. The part "type: String" seems to me to not fit into any standard ruby syntax and I was curious how does mongoid implement that ? class Step include Mongoid::Document field :Label, type: String field :Descript, type: String field :ErrorText, type: String embedded_in :step_data end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0e81b056-62c2-403b-aed1-a4e6892a4648%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
It''s the new hash syntax introduced in ruby 1.9. On Oct 23, 2013 11:22 PM, "Jedrin" <jrubiando-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > In mongoid, a ORM mapped database object is like below. The part "type: > String" seems to me to not fit into any standard ruby syntax and I was > curious how does mongoid implement that ? > > > class Step > include Mongoid::Document > > field :Label, type: String > field :Descript, type: String > field :ErrorText, type: String > > embedded_in :step_data > > end > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/0e81b056-62c2-403b-aed1-a4e6892a4648%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BsTbyvy%2BJ-ZrD4UcJxkY2HJV_nA-7MC0Q4%3D2UUE7T4_%2B3AP-Q%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
That is valid hash syntax. You''re call a method with a signature like:
def field(field_name, options = {})
...
end
field_name is a symbol, options is a hash where the keys are symbols and
the values are constants (class objects).
On Wednesday, October 23, 2013 9:30:28 PM UTC-4, Dheeraj Kumar
wrote:>
> It''s the new hash syntax introduced in ruby 1.9.
> On Oct 23, 2013 11:22 PM, "Jedrin"
<jrub...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>>
> wrote:
>
>>
>> In mongoid, a ORM mapped database object is like below. The part
"type:
>> String" seems to me to not fit into any standard ruby syntax and I
was
>> curious how does mongoid implement that ?
>>
>>
>> class Step
>> include Mongoid::Document
>>
>> field :Label, type: String
>> field :Descript, type: String
>> field :ErrorText, type: String
>>
>> embedded_in :step_data
>>
>> end
>>
>> --
>> You received this message because you are subscribed to the Google
Groups
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send
an
>> email to rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
<javascript:>.
>> To post to this group, send email to
rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:>
>> .
>> To view this discussion on the web visit
>>
https://groups.google.com/d/msgid/rubyonrails-talk/0e81b056-62c2-403b-aed1-a4e6892a4648%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/80ffb62b-384e-497d-9f2b-9832c702ea9f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.