Module: GSGraph::Connections::Settings
- Included in:
- Page
- Defined in:
- lib/gs_graph/connections/settings.rb
Constant Summary collapse
- AVAILABLE_SETTINGS =
[ :users_can_post, :users_can_post_photos, :users_can_tag_photos, :users_can_post_videos ]
Class Method Summary collapse
Instance Method Summary collapse
- #disable!(setting, options = {}) ⇒ Object
- #enable!(setting, options = {}) ⇒ Object
- #settings(options = {}) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gs_graph/connections/settings.rb', line 11 def self.included(klass) AVAILABLE_SETTINGS.each do |setting| klass.class_eval <<-SETTING def #{setting}?(options = {}) settings(options).include? :#{setting} end def #{setting}!(options = {}) enable! :#{setting}, options end def #{setting.to_s.sub('can', 'cannot')}!(options = {}) disable! :#{setting}, options end SETTING end end |
Instance Method Details
#disable!(setting, options = {}) ⇒ Object
41 42 43 |
# File 'lib/gs_graph/connections/settings.rb', line 41 def disable!(setting, = {}) __update_setting__ setting, false, end |
#enable!(setting, options = {}) ⇒ Object
37 38 39 |
# File 'lib/gs_graph/connections/settings.rb', line 37 def enable!(setting, = {}) __update_setting__ setting, true, end |
#settings(options = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/gs_graph/connections/settings.rb', line 29 def settings( = {}) @settings = nil if [:no_cache] @settings ||= self.connection(:settings, ).inject([]) do |_settings_, _setting_| _settings_ << _setting_[:setting].downcase.to_sym if _setting_[:value] _settings_ end end |