Module: Collabda::ClassMethods
- Defined in:
- lib/collabda.rb
Instance Method Summary collapse
- #all ⇒ Object
- #build_collection ⇒ Object
- #check_validity ⇒ Object
- #each(&block) ⇒ Object
- #parsed_data ⇒ Object
- #properties(*attributes) ⇒ Object
- #register_model(model) ⇒ Object
- #source(path, options = {}) ⇒ Object
- #source_path ⇒ Object
Instance Method Details
#all ⇒ Object
47 48 49 |
# File 'lib/collabda.rb', line 47 def all @collabda_models || [] end |
#build_collection ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/collabda.rb', line 65 def build_collection check_validity fetch_data @collabda_models = [] @parsed_data.each do |el| self.new(el) end end |
#check_validity ⇒ Object
60 61 62 63 |
# File 'lib/collabda.rb', line 60 def check_validity raise InvalidSource if @source_path.nil? raise MissingAttributes if @properties.nil? end |
#each(&block) ⇒ Object
56 57 58 |
# File 'lib/collabda.rb', line 56 def each(&block) all.each(&block) end |
#parsed_data ⇒ Object
82 83 84 |
# File 'lib/collabda.rb', line 82 def parsed_data @parsed_data end |
#properties(*attributes) ⇒ Object
74 75 76 |
# File 'lib/collabda.rb', line 74 def properties(*attributes) @properties=attributes end |
#register_model(model) ⇒ Object
51 52 53 54 |
# File 'lib/collabda.rb', line 51 def register_model(model) @collabda_models ||= [] @collabda_models << model end |
#source(path, options = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/collabda.rb', line 41 def source(path, ={}) @source_path = path @format = [:type] || :yaml fetch_data end |
#source_path ⇒ Object
78 79 80 |
# File 'lib/collabda.rb', line 78 def source_path @source_path end |