Class: CanTango::PermissionEngine::YamlStore
- Defined in:
- lib/cantango/permission_engine/yaml_store.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Store
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ YamlStore
constructor
for a YamlStore, the name is the name of the yml file options: extension, path.
- #load! ⇒ Object
- #load_from_hash(hash) ⇒ Object
-
#permissions ⇒ Object
@stanislaw: don’t like this, because what if loader#load! will be called twice during object’s (YamlStore.new) life time!.
- #save!(perms = nil) ⇒ Object
- #save_permissions(perms) ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ YamlStore
for a YamlStore, the name is the name of the yml file options: extension, path
11 12 13 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 11 def initialize name, = {} super end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 6 def path @path end |
Class Method Details
.create(name, options = {}) ⇒ Object
15 16 17 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 15 def self.create name, = {} super end |
Instance Method Details
#load! ⇒ Object
19 20 21 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 19 def load! loader.load! end |
#load_from_hash(hash) ⇒ Object
23 24 25 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 23 def load_from_hash hash loader.load_from_hash hash end |
#permissions ⇒ Object
@stanislaw: don’t like this, because what if loader#load! will be called twice during object’s (YamlStore.new) life time!
29 30 31 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 29 def @permissions ||= loader. end |
#save!(perms = nil) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 60 def save! perms = nil (perms) if perms File.open(file_path, 'w') do |f| f.write to_yaml end end |
#save_permissions(perms) ⇒ Object
68 69 70 |
# File 'lib/cantango/permission_engine/yaml_store.rb', line 68 def (perms) load_from_hash perms end |