Module: JasonObjectMetaProperties::MetaProperties
- Defined in:
- lib/medea/meta_properties.rb
Instance Method Summary collapse
- #_class_options {|opts| ... } ⇒ Object
- #create_member_list(list_name, list_class, list_type) ⇒ Object
- #has_attachment(attachment_name) ⇒ Object
- #has_location ⇒ Object
- #has_many(list_name, list_class) ⇒ Object
- #key_field(field_name) ⇒ Object
- #owns_many(list_name, list_class) ⇒ Object
-
#public(*args) ⇒ Object
sets the default public/private status for objects in this class.
Instance Method Details
#_class_options {|opts| ... } ⇒ Object
7 8 9 10 11 12 |
# File 'lib/medea/meta_properties.rb', line 7 def &block self.send(:class_variable_set, :@@opts, {}) unless self.send(:class_variable_defined?, :@@opts) opts = self.send(:class_variable_get, :@@opts) yield opts self.send(:class_variable_set, :@@opts, opts) end |
#create_member_list(list_name, list_class, list_type) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/medea/meta_properties.rb', line 14 def create_member_list list_name, list_class, list_type do |o| o[:lists] ||= {} o[:lists][list_name] = [list_class, list_type] end define_method(list_name) do #puts "Looking at the #{list_name.to_s} list, which is full of #{list_type.name}s" Medea::JasonListProperty.new self, list_name, list_class, list_type end end |
#has_attachment(attachment_name) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/medea/meta_properties.rb', line 38 def do |o| o[:attachments] ||= [] o[:attachments] << o[:attachments].uniq! end end |
#has_location ⇒ Object
46 47 48 49 50 |
# File 'lib/medea/meta_properties.rb', line 46 def has_location do |o| o[:located] = true end end |
#has_many(list_name, list_class) ⇒ Object
26 27 28 |
# File 'lib/medea/meta_properties.rb', line 26 def has_many list_name, list_class create_member_list list_name, list_class, :reference end |
#key_field(field_name) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/medea/meta_properties.rb', line 66 def key_field field_name #this field must be present to save, and it must be unique do |o| o[:key_fields] ||= [] o[:key_fields] << field_name o[:key_fields].uniq! end end |
#owns_many(list_name, list_class) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/medea/meta_properties.rb', line 30 def owns_many list_name, list_class create_member_list list_name, list_class, :value #also modify the items in the list so that they know that they're owned #list_type.class_variable_set :@@owner, self list_class.owned = true end |
#public(*args) ⇒ Object
sets the default public/private status for objects in this class
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/medea/meta_properties.rb', line 53 def public *args verbs = [:GET, :POST, :PUT, :DELETE] args.reject! do |i| not verbs.include? i end do |o| o[:public] ||= [] o[:public] << args o[:public].flatten! o[:public].uniq! end end |