magerecord 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/magerecord/eav_record.rb +20 -11
- data/lib/magerecord/order_item.rb +6 -1
- data/magerecord.gemspec +2 -2
- metadata +3 -3
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.1. | 
| 1 | 
            +
            0.1.3
         | 
| @@ -24,11 +24,29 @@ module MageRecord | |
| 24 24 |  | 
| 25 25 |  | 
| 26 26 | 
             
                def method_missing(meth, *args, &block)
         | 
| 27 | 
            +
                  eav = get_eav_records(meth)
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  if eav.count > 0
         | 
| 30 | 
            +
                    # return value of Magento EAV attribute if available
         | 
| 31 | 
            +
                    eav.first
         | 
| 32 | 
            +
                  else
         | 
| 33 | 
            +
                    # call superclass's method_missing method
         | 
| 34 | 
            +
                    # or risk breaking Ruby's method lookup
         | 
| 35 | 
            +
                    super
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
             | 
| 40 | 
            +
             | 
| 41 | 
            +
             | 
| 42 | 
            +
                private
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def get_eav_records(attrib_sym)
         | 
| 27 45 | 
             
                  conn = self.class.connection
         | 
| 28 46 | 
             
                  eav_prefix = self.class.eav_prefix
         | 
| 29 47 |  | 
| 30 48 | 
             
                  # note: select_values returns just one value from a single db column
         | 
| 31 | 
            -
                   | 
| 49 | 
            +
                  conn.select_values <<-RAWSQL.strip_heredoc
         | 
| 32 50 | 
             
                    SELECT
         | 
| 33 51 | 
             
                      CASE ea.backend_type
         | 
| 34 52 | 
             
                        WHEN 'varchar'  THEN entity_varchar.value
         | 
| @@ -61,18 +79,9 @@ module MageRecord | |
| 61 79 | 
             
                    LEFT JOIN #{eav_prefix}_entity_decimal  AS entity_decimal ON entity.entity_id = entity_decimal.entity_id AND ea.attribute_id = entity_decimal.attribute_id AND ea.backend_type = 'decimal'
         | 
| 62 80 | 
             
                    LEFT JOIN #{eav_prefix}_entity_datetime AS entity_datetime ON entity.entity_id = entity_datetime.entity_id AND ea.attribute_id = entity_datetime.attribute_id AND ea.backend_type = 'datetime'
         | 
| 63 81 |  | 
| 64 | 
            -
                    WHERE ea.attribute_code = #{conn.quote( | 
| 82 | 
            +
                    WHERE ea.attribute_code = #{conn.quote(attrib_sym)}
         | 
| 65 83 | 
             
                      AND entity.entity_id = #{id}
         | 
| 66 84 | 
             
                  RAWSQL
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                  if eav.count > 0
         | 
| 69 | 
            -
                    # return value of Magento EAV attribute if available
         | 
| 70 | 
            -
                    eav.first
         | 
| 71 | 
            -
                  else
         | 
| 72 | 
            -
                    # call superclass's method_missing method
         | 
| 73 | 
            -
                    # or risk breaking Ruby's method lookup
         | 
| 74 | 
            -
                    super
         | 
| 75 | 
            -
                  end
         | 
| 76 85 | 
             
                end
         | 
| 77 86 | 
             
              end
         | 
| 78 87 | 
             
            end
         | 
| @@ -15,7 +15,12 @@ module MageRecord | |
| 15 15 |  | 
| 16 16 | 
             
                # call associated product's method
         | 
| 17 17 | 
             
                def method_missing(meth, *args, &block)
         | 
| 18 | 
            -
                   | 
| 18 | 
            +
                  super || (product && product.send(meth))
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
             | 
| 22 | 
            +
                def respond_to?(meth, include_private = false)
         | 
| 23 | 
            +
                  super || (product && product.respond_to?(meth))
         | 
| 19 24 | 
             
                end
         | 
| 20 25 | 
             
              end
         | 
| 21 26 | 
             
            end
         | 
    
        data/magerecord.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = "magerecord"
         | 
| 8 | 
            -
              s.version = "0.1. | 
| 8 | 
            +
              s.version = "0.1.3"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Marc"]
         | 
| 12 | 
            -
              s.date = "2014- | 
| 12 | 
            +
              s.date = "2014-05-09"
         | 
| 13 13 | 
             
              s.description = "A simple ActiveRecord wrapper for various Magento models"
         | 
| 14 14 | 
             
              s.email = "xerokill@gmail.com"
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: magerecord
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.3
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2014- | 
| 12 | 
            +
            date: 2014-05-09 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: activerecord
         | 
| @@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 170 170 | 
             
                  version: '0'
         | 
| 171 171 | 
             
                  segments:
         | 
| 172 172 | 
             
                  - 0
         | 
| 173 | 
            -
                  hash: - | 
| 173 | 
            +
                  hash: -2096501154630265700
         | 
| 174 174 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 175 175 | 
             
              none: false
         | 
| 176 176 | 
             
              requirements:
         |