selected 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/selected.rb +24 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9052c1603d3165db19fa8e168e7d9038a40911fe
4
+ data.tar.gz: 29f329975847bff3f5c51b6a4fb8177f4a696827
5
+ SHA512:
6
+ metadata.gz: 9c34f71b5091b16680a8912419a719d32d3ace1c0829bcdb797284ecd5d4e86f31ee318908c1f80f4cc6126dd4ddcce763ea43a051d9910a154852fb9c724829
7
+ data.tar.gz: c36b35d3a942f4c0c1021a3d7fc8549bdf65ee0a80f1eb0fa56c674127fa4d9e73962f75fdaca026cf0b7577b75cf0b08f6297b48c795831e03c47f3910f23b1
data/lib/selected.rb ADDED
@@ -0,0 +1,24 @@
1
+ class Selected
2
+ def self.selected?(controller_name, action_name="", id="")
3
+ unless action_name.present?
4
+ action_name = params[:action]
5
+ end
6
+ unless id.present?
7
+ id = params[:id]
8
+ end
9
+
10
+ if controller_matches(controller_name) && action_matches(action_name) && params[:id] == id
11
+ "selected"
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def controller_matches(controller_name)
18
+ params[:controller] == controller_name.to_s
19
+ end
20
+
21
+ def action_matches(action_name)
22
+ (action_name.respond_to?(:each) && action_name.map(&:to_s).include?(params[:action])) || params[:action] == action_name.to_s
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: selected
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thibaut Assus
8
+ - Melissa Grach
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-15 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple gem to know if a link should get the selected class
15
+ email: thibaut@milesrock.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/selected.rb
21
+ homepage: http://rubygems.org/gems/selected
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.2.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Selected
45
+ test_files: []