Module: Shopifydev::Faker
Instance Method Summary collapse
Instance Method Details
#key ⇒ Object
40 41 42 |
# File 'lib/shopifydev/faker.rb', line 40 def key ::Faker::Lorem.word.downcase end |
#metafield(owner = nil, opts = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/shopifydev/faker.rb', line 9 def (owner=nil, opts={}) owner_resource = owner && owner.class.element_name owner_id = owner && owner.id = ::ShopifyAPI::Metafield.new( { owner_resource: owner_resource, owner_id: owner_id, namespace: opts[:namespace] || namespace, key: opts[:key] || key, value_type: 'string', value: opts[:value] || value } ) .save! if owner_id end |
#namespace ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/shopifydev/faker.rb', line 26 def namespace s = '' loop do word = ::Faker::Lorem.word[0..rand(10)].downcase word = '.' + word if s.length > 0 if (s.length + word.length) < 21 s += word else break end end s end |
#value ⇒ Object
44 45 46 |
# File 'lib/shopifydev/faker.rb', line 44 def value ::Faker::Lorem.sentence(rand(10)) end |