Class: Symbol

Inherits:
Object show all
Includes:
Spec::Expectations::StringHelpers
Defined in:
lib/mack/core_extensions/symbol.rb,
lib/gems/rspec-1.1.12/lib/spec/expectations/extensions/string_and_symbol.rb

Instance Method Summary collapse

Methods included from Spec::Expectations::StringHelpers

#starts_with?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



3
4
5
# File 'lib/mack/core_extensions/symbol.rb', line 3

def method_missing(sym, *args)
  self.to_s.send(sym, *args)
end

Instance Method Details

#check_box(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers check_box for more information

Examples:

@user = User.new(:accepted_tos => true)
<%= :user.check_box :accepted_tos %> # => <input checked="checked" id="user_accepted_tos" name="user[accepted_tos]" type="checkbox" />
<%= :i_dont_exist.check_box %> # => <input id="i_dont_exist" name="i_dont_exist" type="checkbox" />


23
24
25
# File 'lib/mack/core_extensions/symbol.rb', line 23

def check_box(*args)
  Thread.current[:view_template].check_box(self, *args)
end

#date_select(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers date_select for more information



13
14
15
# File 'lib/mack/core_extensions/symbol.rb', line 13

def date_select(*args)
  Thread.current[:view_template].date_select(self, *args)
end

#date_time_select(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers date_time_select for more information



8
9
10
# File 'lib/mack/core_extensions/symbol.rb', line 8

def date_time_select(*args)
  Thread.current[:view_template].date_time_select(self, *args)
end

#file_field(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers file_field for more information

Examples:

@user = User.new(:bio_file => "~/bio.doc")
<%= :user.file_field :bio_file %> # => <input id="user_bio_field" name="user[bio_field]" type="file" value="~/bio.doc" />
<%= :i_dont_exist.file_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="file" value="" />


33
34
35
# File 'lib/mack/core_extensions/symbol.rb', line 33

def file_field(*args)
  Thread.current[:view_template].file_field(self, *args)
end

#hidden_field(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers hidden_field for more information

Examples:

@user = User.new(:email => "[email protected]")
<%= :user.hidden_field :email %> # => <input id="user_email" name="user[email]" type="hidden" value="[email protected]" />
<%= :i_dont_exist.hidden_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="hidden" />


43
44
45
# File 'lib/mack/core_extensions/symbol.rb', line 43

def hidden_field(*args)
  Thread.current[:view_template].hidden_field(self, *args)
end

#label_tag(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers label_tag for more information

Examples:

@user = User.new
<%= :user.label_tag :email %> # => <label for="user_email">Email</label>
<%= :i_dont_exist.label_tag %> # => <label for="i_dont_exist">I don't exist</label>
<%= :i_dont_exist.label_tag :value => "Hello" %> # => <label for="i_dont_exist">Hello</label>


54
55
56
# File 'lib/mack/core_extensions/symbol.rb', line 54

def label_tag(*args)
  Thread.current[:view_template].label_tag(self, *args)
end

#password_field(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers password_field for more information

Examples:

@user = User.new(:email => "[email protected]")
<%= :user.password_field :email %> # => <input id="user_email" name="user[email]" type="password" value="[email protected]" />
<%= :i_dont_exist.password_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="password" />


64
65
66
# File 'lib/mack/core_extensions/symbol.rb', line 64

def password_field(*args)
  Thread.current[:view_template].password_field(self, *args)
end

#radio_button(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers radio_button for more information

Examples:

@user = User.new(:level => 1)
<%= :user.radio_button :level %> # => <input checked="checked" id="user_level" name="user[level]" type="radio" value="1" />
<%= :user.radio_button :level, :value => 2 %> # => <input id="user_level" name="user[level]" type="radio" value="2" />
<%= :i_dont_exist.radio_button %> # => <input id="i_dont_exist" name="i_dont_exist" type="radio" value="" />


75
76
77
# File 'lib/mack/core_extensions/symbol.rb', line 75

def radio_button(*args)
  Thread.current[:view_template].radio_button(self, *args)
end

#select_tag(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers select_tag for more information

Examples:

@user = User.new(:level => 1)
<%= :user.select_tag :level, :options => [["one", 1], ["two", 2]] %> # => <select id="user_level" name="user[level]"><option value="1" selected>one</option><option value="2" >two</option></select>
<%= :user.select_tag :level, :options => {:one => 1, :two => 2} %> # => <select id="user_level" name="user[level]"><option value="1" selected>one</option><option value="2" >two</option></select>
<%= :i_dont_exist.select_tag :options => [["one", 1], ["two", 2]], :selected => 1 %> # => <select id="i_dont_exist" name="i_dont_exist"><option value="1" selected>one</option><option value="2" >two</option></select>


86
87
88
# File 'lib/mack/core_extensions/symbol.rb', line 86

def select_tag(*args)
  Thread.current[:view_template].select_tag(self, *args)
end

#text_area(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers text_area for more information

Examples:

@user = User.new(:bio => "my bio here")
<%= :user.text_area :bio %> # => <textarea id="user_bio" name="user[bio]">my bio here</textarea>
<%= :i_dont_exist.text_area %> # => <textarea id="i_dont_exist" name="i_dont_exist"></textarea>
<%= :i_dont_exist.text_area :value => "hi there" %> # => <textarea id="i_dont_exist" name="i_dont_exist">hi there</textarea>


97
98
99
# File 'lib/mack/core_extensions/symbol.rb', line 97

def text_area(*args)
  Thread.current[:view_template].text_area(self, *args)
end

#text_field(*args) ⇒ Object

See Mack::ViewHelpers::FormHelpers text_field for more information

Examples:

@user = User.new(:email => "[email protected]")
<%= :user.text_field :email %> # => <input id="user_email" name="user[email]" type="text" value="[email protected]" />
<%= :i_dont_exist.text_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="text" />


107
108
109
# File 'lib/mack/core_extensions/symbol.rb', line 107

def text_field(*args)
  Thread.current[:view_template].text_field(self, *args)
end