Module: EasyType::YamlType
- Defined in:
- lib/easy_type/yaml_type.rb
Overview
module to include in a yaml based type
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #add ⇒ Object
- #current_config ⇒ Object
- #on_apply ⇒ Object
- #on_create ⇒ Object
- #on_modify ⇒ Object
- #remove ⇒ Object
Class Method Details
.included(parent) ⇒ Object
17 18 19 20 |
# File 'lib/easy_type/yaml_type.rb', line 17 def self.included(parent) parent.include(EasyType) parent.extend(ClassMethods) end |
Instance Method Details
#add ⇒ Object
36 37 38 39 |
# File 'lib/easy_type/yaml_type.rb', line 36 def add self.class.get_raw_resources on_apply end |
#current_config ⇒ Object
75 76 77 |
# File 'lib/easy_type/yaml_type.rb', line 75 def current_config self.class.configuration.fetch(name) { {} } end |
#on_apply ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/easy_type/yaml_type.rb', line 56 def on_apply merge_configuration # # Let all properties do there own on_modify stuff before we save it. # This is a bit of a hack, because easy_type will call the on_modify # method anyway.....but after the data has already been saved. # properties.each do |property| if property.respond_to?(:on_modify) property.on_modify elsif property.respond_to?('on_apply') property.on_apply end end write_yaml secure_yaml nil end |
#on_create ⇒ Object
48 49 50 |
# File 'lib/easy_type/yaml_type.rb', line 48 def on_create on_apply end |
#on_modify ⇒ Object
52 53 54 |
# File 'lib/easy_type/yaml_type.rb', line 52 def on_modify on_apply end |
#remove ⇒ Object
41 42 43 44 45 46 |
# File 'lib/easy_type/yaml_type.rb', line 41 def remove self.class.get_raw_resources self.class.configuration.delete(name) write_yaml secure_yaml end |