Module: Chargify::Behaviors::Metadata::ClassMethods
- Defined in:
- lib/chargify_api_ares/behaviors/metadata.rb
Instance Method Summary collapse
- #endpoint_name=(name) ⇒ Object
- #instantiate_collection(collection, prefix_options = {}) ⇒ Object
- #instantiate_record(record, prefix_options = {}) ⇒ Object
Instance Method Details
#endpoint_name=(name) ⇒ Object
41 42 43 44 |
# File 'lib/chargify_api_ares/behaviors/metadata.rb', line 41 def endpoint_name=(name) (class << self; self; end).send(:define_method, :resource) do; name; end (class << self; self; end).send(:define_method, :element_name) do; name; end end |
#instantiate_collection(collection, prefix_options = {}) ⇒ Object
47 48 49 |
# File 'lib/chargify_api_ares/behaviors/metadata.rb', line 47 def instantiate_collection(collection, original_params = {}, = {}) collection[self.resource].collect! { |record| instantiate_record(record, ) } end |
#instantiate_record(record, prefix_options = {}) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/chargify_api_ares/behaviors/metadata.rb', line 56 def instantiate_record(record, = {}) record = record.is_a?(Array) ? record.first : record new(record, true).tap do |resource| resource. = resource.current_name = resource.name end end |